diff --git a/netbox/extras/models/customfields.py b/netbox/extras/models/customfields.py index 974affb2e..240998146 100644 --- a/netbox/extras/models/customfields.py +++ b/netbox/extras/models/customfields.py @@ -660,6 +660,10 @@ class CustomField(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel): # Validate date & time elif self.type == CustomFieldTypeChoices.TYPE_DATETIME: if type(value) is not datetime: + # Work around UTC issue for Python < 3.11; see + # https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat + if type(value) is str and value.endswith('Z'): + value = f'{value[:-1]}+00:00' try: datetime.fromisoformat(value) except ValueError: diff --git a/netbox/utilities/templates/builtins/customfield_value.html b/netbox/utilities/templates/builtins/customfield_value.html index 462e62b86..dbf10e1bf 100644 --- a/netbox/utilities/templates/builtins/customfield_value.html +++ b/netbox/utilities/templates/builtins/customfield_value.html @@ -11,7 +11,7 @@ {% elif customfield.type == 'date' and value %} {{ value|isodate }} {% elif customfield.type == 'datetime' and value %} - {{ value|isodate }} {{ value|isodatetime }} + {{ value|isodatetime }} {% elif customfield.type == 'url' and value %} {{ value|truncatechars:70 }} {% elif customfield.type == 'json' and value %}