Skip to content

Commit

Permalink
fix: refactor VLAN model by removing device foreign key
Browse files Browse the repository at this point in the history
  • Loading branch information
djothi committed Dec 14, 2023
1 parent ef174e7 commit 3cb8572
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('netbox_cmdb', '0035_vlan'),
]

operations = [
migrations.AlterUniqueTogether(
name='vlan',
unique_together=set(),
),
migrations.RemoveField(
model_name='vlan',
name='device',
),
]
10 changes: 1 addition & 9 deletions netbox_cmdb/netbox_cmdb/models/vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ class VLAN(ChangeLoggedModel):
validators=(MinValueValidator(VLAN_VID_MIN), MaxValueValidator(VLAN_VID_MAX)),
)
name = models.CharField(max_length=64)
device = models.ForeignKey(
to="dcim.Device",
on_delete=models.CASCADE,
related_name="%(class)sdevice",
null=False,
blank=False,
)
description = models.CharField(max_length=100, blank=True)
tenant = models.ForeignKey(
to="tenancy.Tenant",
Expand All @@ -34,10 +27,9 @@ class VLAN(ChangeLoggedModel):
)

def __str__(self):
return f"{self.device.name}--{self.name}"
return f"{self.name}"

class Meta:
ordering = ["vid"]
unique_together = ("device", "name")
verbose_name = "VLAN"
verbose_name_plural = "VLANs"

0 comments on commit 3cb8572

Please sign in to comment.