Model cleanup

This commit is contained in:
Brian Tiemann 2024-11-14 13:12:31 -05:00
parent 90cf71ba58
commit e46d9a6d29
2 changed files with 4 additions and 6 deletions

View File

@ -60,8 +60,8 @@ class Migration(migrations.Migration):
('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)),
('description', models.CharField(blank=True, max_length=200)),
('comments', models.TextField(blank=True)),
('mac_address', dcim.fields.MACAddressField(blank=True, null=True)),
('is_primary', models.BooleanField(default=False)),
('mac_address', dcim.fields.MACAddressField()),
('is_primary', models.BooleanField(default=True)),
('assigned_object_id', models.PositiveBigIntegerField(blank=True, null=True)),
('assigned_object_type', models.ForeignKey(blank=True, limit_choices_to=models.Q(models.Q(models.Q(('app_label', 'dcim'), ('model', 'interface')), models.Q(('app_label', 'virtualization'), ('model', 'vminterface')), _connector='OR')), null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.contenttype')),
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),

View File

@ -1484,8 +1484,6 @@ class VirtualDeviceContext(PrimaryModel):
class MACAddress(PrimaryModel):
mac_address = MACAddressField(
null=True,
blank=True,
verbose_name=_('MAC address')
)
assigned_object_type = models.ForeignKey(
@ -1506,7 +1504,7 @@ class MACAddress(PrimaryModel):
)
is_primary = models.BooleanField(
verbose_name=_('is primary for interface'),
default=False
default=True
)
class Meta:
@ -1515,7 +1513,7 @@ class MACAddress(PrimaryModel):
verbose_name_plural = _('MAC addresses')
def __str__(self):
return f'{str(self.mac_address)} {self.assigned_object}'
return str(self.mac_address)
def clean(self):
super().clean()