URLField
class
URLField
A field for validating URLs.
URLField(
*,
required: bool = True,
default: Any = None,
schemes: collections.abc.Iterable[str] | None = None,
one_of: collections.abc.Iterable[str] | None = None,
messages: dict[str, str] | None = None
)
Bases: Field
| 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 |
schemes |
URL/URI scheme list to validate against. If not provided, the default list is ["http", "https"]. |
pattern |
A regex pattern that the string must match. Defaults to |
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"}. |
Even if the format is valid, it cannot guarantee that the URL is real. The purpose of this function is to alert the user of a typing mistake.
Perform an UTS-46 normalization of the domain, which includes lowercasing (domain names are case-insensitive), NFC normalization, and converting all label separators (the period/full stop, fullwidth full stop, ideographic full stop, and halfwidth ideographic full stop) to basic periods.