Fields
NoParamURLField
Bases: URLField
A URLField that stores URLs without query parameters or fragments.
This field extends Django's URLField to store only the domain and path components of URLs, stripping away query parameters and fragments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
Variable length argument list passed to URLField. |
required | |
**kwargs
|
Arbitrary keyword arguments passed to URLField. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
The processed URL containing only domain and path. |
|
None |
If the input cannot be parsed as a valid URL. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the URL doesn't contain both domain and path components. |
Examples:
>>> field = NoParamURLField()
>>> field.get_prep_value('https://example.com/path?query=1#fragment')
'example.com/path'
Source code in django_util/fields.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
UpperTextField
Bases: TextField
A TextField that converts input to uppercase and strips whitespace.
This field extends Django's TextField to automatically convert stored values to uppercase and remove leading/trailing whitespace.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
Variable length argument list passed to TextField. |
required | |
**kwargs
|
Arbitrary keyword arguments passed to TextField. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
The processed string in uppercase with stripped whitespace. |
|
None |
If the input cannot be converted to a string. |
Examples:
>>> field = UpperTextField()
>>> field.get_prep_value(" hello world ")
'HELLO WORLD'
>>> field.get_prep_value(None)
None
Source code in django_util/fields.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|