Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

As a difference from the Date Field, DateTime Field is capable of changing the DateTime time zone easing the process of localization.

...

Schema Details

Parameter
PropertyTypeDescriptionRequiredDefault
RequiredDescriptionformatUnion[str]'%Y-%m-%d'False
Enum
typestringThe type of field.Nodate_timedate_time
labelstring/nullLabel to show for this field.Nonull
css_styleobject/nullStyle to apply in the HTML of the UI.Nonull
css_classstring/nullCSS class to apply in the HTML component.Nonull
translatestring/nullTranslation key
Format
for the field.
timezoneUnion[str, None]-FalseTimezone for the field.

_DateFieldUI

...

Nonull
translate_labelstring/nullTranslation key for the label.Nonull
analyticsobject/nullAnalytics configuration.Nonull
if_not_existstring/nullShow only if the specified field doesn't exist.Nonull
if_existstring/nullShow only if the specified field does exist.Nonull
only_on_highlightbooleanShow only when the value is highlighted.Nofalse
displayanyValue from the field.Nonull
fieldstringPath to field from which to retrieve the value (in JMESPath format).Yes

field_highlightstring/nullPath to highlight field from which to retrieve the value, in case it is not the same as the field parameter (in JMESPath format).Nonull
defaultanyDefault value to use in case no value was found for the field.Nonull
transformarray/string/nullList of transformations to apply to the displayed values.Nonull
suffixstring/nullSuffix to append to the value or values.Nonull
prefixstring/nullPrefix to append to the value or values.Nonull
suffix_labelstring/nullSuffix to append to the label of the field.Nonull
prefix_labelstring/nullPrefix to append to the label of the field.Nonull
sortstring/booleanSort order for values in an array.Nofalseasc, desc
uniquebooleanIf the values are in an array, remove the duplicates.Nofalse
show_blankbooleanIf there is no value, or value is null, and show_blank is true, keep the field.Nofalse
replacementstring/nullReplacement string for matches in the transformations Transformation.REPLACE_FIRST, Transformation.REPLACE_LAST, and Transformation.REPLACE_ALL.Nonull
patternstring/nullPattern used to look for matches in the transformations Transformation.REPLACE_FIRST, Transformation.REPLACE_LAST, and Transformation.REPLACE_ALL.Nonull
formatstringFormat of the date and time value.No%Y-%m-%d %H:%M:%S
timezonestring/nullTimezone for the date and time value.Nonull

Example JSON Representation

Code Block
languagejs
themeDJango
{
  "type": "date_time",
  "label": "Last Login",
  "css_style": null,
  "css_class": null,
  "translate": null,
  "translate_label": null,
  "analytics": null,
  "if_not_exist": null,
  "if_exist": null,
  "only_on_highlight": false,
  "display": null,
  "field": "last_login",
  "field_highlight": null,
  "default": null,
  "transform": null,
  "suffix": null,
  "prefix": null,
  "suffix_label": null,
  "prefix_label": null,
  "sort": false,
  "unique": false,
  "show_blank": false,
  "replacement": null,
  "pattern": null,
  "format": "%Y-%m-%d %H:%M:%S",
  "timezone": "UTC"
}

Code Example of Usage

Code Block
themeDJango
date_time_field_example = DateTimeField(
    field="last_login",
    format="

Example Configuration

Code Block
languagepy
themeDJango
DateTimeField(field='data.launch_time', format='%Y-%m-%d %H:%M', timezone='etc/GMT+6'):%S",
    timezone="UTC"
)
Warning
titleKnown Issues

Parsed string dates with attached time zones may behave unpredictably, as the date time is interpreted backwards by the string date parser, an example of faulty date is "2012-01-19 19:21:00 GMT+2"


This was fixed on version 3.1.