diff --git a/netbox/utilities/management/commands/__init__.py b/netbox/utilities/management/commands/__init__.py index 697a3ed9a..bdd4face6 100644 --- a/netbox/utilities/management/commands/__init__.py +++ b/netbox/utilities/management/commands/__init__.py @@ -1,11 +1,16 @@ from django.db import models +from timezone_field import TimeZoneField -EXEMPT_ATTRS = [ +SKIP_FIELDS = ( + TimeZoneField, +) + +EXEMPT_ATTRS = ( 'choices', 'help_text', 'verbose_name', -] +) _deconstruct = models.Field.deconstruct @@ -17,12 +22,8 @@ def custom_deconstruct(field): name, path, args, kwargs = _deconstruct(field) # Remove any ignored attributes - for attr in EXEMPT_ATTRS: - kwargs.pop(attr, None) - - # A hack to accommodate TimeZoneField, which employs a custom deconstructor to check whether the default choices - # have changed - if hasattr(field, 'CHOICES'): - kwargs['choices'] = field.CHOICES + if field.__class__ not in SKIP_FIELDS: + for attr in EXEMPT_ATTRS: + kwargs.pop(attr, None) return name, path, args, kwargs diff --git a/requirements.txt b/requirements.txt index 1da0ad4c4..761078804 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ django-redis==5.0.0 django-rq==2.4.1 django-tables2==2.4.0 django-taggit==1.5.1 -django-timezone-field==4.1.2 +django-timezone-field==4.2.1 djangorestframework==3.12.4 drf-yasg[validation]==1.20.0 graphene_django==2.15.0