Skip to content

Commit

Permalink
#17761: Set null=True on Site.time_zone
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Nov 25, 2024
1 parent b841875 commit d093b21
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions netbox/dcim/migrations/0194_charfield_null_choices.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import timezone_field.fields
from django.db import migrations, models


Expand All @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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),
]
3 changes: 2 additions & 1 deletion netbox/dcim/models/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit d093b21

Please sign in to comment.