Form Fields¶
TimeZoneField¶
-
class
djem.forms.TimeZoneField(**kwargs)[source]¶ A
TypedChoiceFieldwith defaults applied forcoerceandchoices.- Default widget:
Select. - Empty value:
''(the empty string), by default. - Normalizes to: a
TimeZoneHelperinstance. - 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
TimeZoneHelperinstance 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
TimeZoneFieldrequires pytz to be installed. Ifpytzis not available, the defaultchoiceslist will be empty and noTimeZoneHelperobjects will be able to be instantiated.Note
Use of
TimeZoneFieldonly makes sense if USE_TZ is True.See also
The
djem.models.TimeZoneFieldmodel field.- Default widget: