Explorar o código

#17761: Set null=True on Site.time_zone

Jeremy Stretch hai 1 ano
pai
achega
d093b21bc0

+ 8 - 0
netbox/dcim/migrations/0194_charfield_null_choices.py

@@ -1,3 +1,4 @@
+import timezone_field.fields
 from django.db import migrations, models
 
 
@@ -24,6 +25,7 @@ def set_null_values(apps, schema_editor):
     Rack = apps.get_model('dcim', 'Rack')
     RackType = apps.get_model('dcim', 'RackType')
     RearPort = apps.get_model('dcim', 'RearPort')
+    Site = apps.get_model('dcim', 'Site')
 
     Cable.objects.filter(length_unit='').update(length_unit=None)
     Cable.objects.filter(type='').update(type=None)
@@ -66,6 +68,7 @@ def set_null_values(apps, schema_editor):
     RackType.objects.filter(outer_unit='').update(outer_unit=None)
     RackType.objects.filter(weight_unit='').update(weight_unit=None)
     RearPort.objects.filter(cable_end='').update(cable_end=None)
+    Site.objects.filter(time_zone='').update(time_zone=None)
 
 
 class Migration(migrations.Migration):
@@ -279,5 +282,10 @@ class Migration(migrations.Migration):
             name='cable_end',
             field=models.CharField(blank=True, max_length=1, null=True),
         ),
+        migrations.AlterField(
+            model_name='site',
+            name='time_zone',
+            field=timezone_field.fields.TimeZoneField(blank=True, null=True),
+        ),
         migrations.RunPython(code=set_null_values, reverse_code=migrations.RunPython.noop),
     ]

+ 2 - 1
netbox/dcim/models/sites.py

@@ -189,7 +189,8 @@ class Site(ContactsMixin, ImageAttachmentsMixin, PrimaryModel):
         blank=True
     )
     time_zone = TimeZoneField(
-        blank=True
+        blank=True,
+        null=True
     )
     physical_address = models.CharField(
         verbose_name=_('physical address'),