SlugField
class
SlugField
In web publishing, a "slug" is a part of a URL which identifies a page in a human-readable way. It is usually a simplified version of the page title, containing only letters, numbers, hyphens or underscores.
SlugField(
*,
required: bool = True,
default: Any = None,
slugify: collections.abc.Callable[[str], str] = <function slugify at 0x787bceafe8e0>,
one_of: collections.abc.Iterable[str] | None = None,
messages: dict[str, str] | None = None
)
Bases: TextField
| Argument | Description |
|---|---|
required |
Whether the field is required. Defaults to |
default |
Default value for the field. Can be a static value or a callable.
Defaults to |
slugify |
Optional callable that replaces the default slugify function. It should take a string and return a slugified version of it. |
one_of |
List of values that the field value must be one of. Defaults to |
messages |
Dictionary of error codes to custom error message templates. These override the default error messages for this specific field. Example: {"required": "This field cannot be empty"}. |
This field convert its input to a valid slug. It uses a very simple
slugify function that removes most non-latin-based characters (cyrillic,
arabic, hebrew, hindi, etc.). You can provided your own slugify function
with the slugify argument.