Explorar o código

Bump django-timezone-field to 4.2.1

jeremystretch %!s(int64=4) %!d(string=hai) anos
pai
achega
85b61c0b7e
Modificáronse 2 ficheiros con 11 adicións e 10 borrados
  1. 10 9
      netbox/utilities/management/commands/__init__.py
  2. 1 1
      requirements.txt

+ 10 - 9
netbox/utilities/management/commands/__init__.py

@@ -1,11 +1,16 @@
 from django.db import models
 from django.db import models
+from timezone_field import TimeZoneField
 
 
 
 
-EXEMPT_ATTRS = [
+SKIP_FIELDS = (
+    TimeZoneField,
+)
+
+EXEMPT_ATTRS = (
     'choices',
     'choices',
     'help_text',
     'help_text',
     'verbose_name',
     'verbose_name',
-]
+)
 
 
 _deconstruct = models.Field.deconstruct
 _deconstruct = models.Field.deconstruct
 
 
@@ -17,12 +22,8 @@ def custom_deconstruct(field):
     name, path, args, kwargs = _deconstruct(field)
     name, path, args, kwargs = _deconstruct(field)
 
 
     # Remove any ignored attributes
     # 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
     return name, path, args, kwargs

+ 1 - 1
requirements.txt

@@ -10,7 +10,7 @@ django-redis==5.0.0
 django-rq==2.4.1
 django-rq==2.4.1
 django-tables2==2.4.0
 django-tables2==2.4.0
 django-taggit==1.5.1
 django-taggit==1.5.1
-django-timezone-field==4.1.2
+django-timezone-field==4.2.1
 djangorestframework==3.12.4
 djangorestframework==3.12.4
 drf-yasg[validation]==1.20.0
 drf-yasg[validation]==1.20.0
 graphene_django==2.15.0
 graphene_django==2.15.0