djem.forms.fields
djem.forms
A TypedChoiceField
with defaults applied for coerce
and choices
.
- Default widget:
Select
. - Empty value:
''
(the empty string), by default. - Normalizes to: a
~djem.utils.dt.TimeZoneHelper
instance. - Validates that the given value exists in the list of choices and can be coerced.
- Error message keys:
required
,invalid_choice
.
TimeZoneField.coerce
Defaults to a function that accepts a timezone name string ('Australia/Sydney', 'US/Eastern', etc) and returns a ~djem.utils.dt.TimeZoneHelper
instance for that timezone.
TimeZoneField.choices
Defaults to a list of 2-tuples containing the timezones provided by pytz.common_timezones. Both items of each 2-tuple simply contain the timezone name. This is equavalient to:
choices = [(tz, tz) for tz in pytz.common_timezones]
Note
Use of TimeZoneField
requires pytz to be installed. If pytz
is not available, the default choices
list will be empty and no ~djem.utils.dt.TimeZoneHelper
objects will be able to be instantiated.
Note
Use of TimeZoneField
only makes sense if USE_TZ is True.
The djem.models.TimeZoneField
model field.