utils
generate_unique_slug_for_model
generate_unique_slug_for_model(
model_class: type[Model],
text: str,
slug_field: str | None = "slug",
max_length_override: int | None = None,
) -> str
Generate a unique slug for the given model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_class |
Model
|
A class based upon |
required |
text |
str
|
Text to convert to a slug. |
required |
slug_field |
str | None
|
The name of the slug field of the model. |
'slug'
|
max_length_override |
int | None
|
Maximum number of characters to use if not the same as what's defined in the slug field. |
None
|
Returns: (str): The generated slug.