SlugField
This class represents a specialized character field intended for storing slugs, which are short labels containing only letters, numbers, underscores, or hyphens. It includes built-in validation to ensure data integrity and supports an optional flag to allow Unicode characters in the slug. This field is typically used in URL construction to provide human-readable identifiers for resources.
Attributes
| Attribute | Type | Description |
|---|---|---|
| default_validators | list = [validators.validate_slug] | A list of validation functions applied to the field, which defaults to slug validation or unicode slug validation if allow_unicode is enabled. |
Constructor
Signature
def SlugField(
allow_unicode: boolean = False,
**kwargs: dict
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| allow_unicode | boolean = False | If True, the field accepts Unicode letters in addition to ASCII letters. |
| **kwargs | dict | Arbitrary keyword arguments passed to the parent CharField constructor. |
Signature
def SlugField(
allow_unicode: boolean = False,
**kwargs: dict
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| allow_unicode | boolean = False | Determines whether the field accepts Unicode characters or is restricted to standard ASCII alphanumeric characters, underscores, and hyphens. |
| **kwargs | dict | Arbitrary keyword arguments passed to the parent CharField constructor for field configuration. |