Form Fields¶
TimeZoneField
¶
- class djem.forms.TimeZoneField(**kwargs)[source]¶
A
TypedChoiceField
with defaults applied forcoerce
andchoices
.Default widget:
Select
.Empty value:
''
(the empty string), by default.Normalizes to: a
TimeZoneHelper
instance.Validates that the given value exists in the list of choices and can be coerced.
Error message keys:
required
,invalid_choice
.
- coerce¶
Defaults to a function that accepts a timezone name string (‘Australia/Sydney’, ‘US/Eastern’, etc) and returns a
TimeZoneHelper
instance for that timezone.
- 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. Ifpytz
is not available, the defaultchoices
list will be empty and noTimeZoneHelper
objects will be able to be instantiated.Note
Use of
TimeZoneField
only makes sense if USE_TZ is True.See also
The
djem.models.TimeZoneField
model field.