Skip to main content

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

AttributeTypeDescription
default_validatorslist = [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

NameTypeDescription
allow_unicodeboolean = FalseIf True, the field accepts Unicode letters in addition to ASCII letters.
**kwargsdictArbitrary keyword arguments passed to the parent CharField constructor.

Signature

def SlugField(
allow_unicode: boolean = False,
**kwargs: dict
) - > null

Parameters

NameTypeDescription
allow_unicodeboolean = FalseDetermines whether the field accepts Unicode characters or is restricted to standard ASCII alphanumeric characters, underscores, and hyphens.
**kwargsdictArbitrary keyword arguments passed to the parent CharField constructor for field configuration.