Skip to content

Commit

Permalink
feat(models): Add related name for NetBox models
Browse files Browse the repository at this point in the history
The detail view of the NetBox tenant model renders a related object
table for any related objects (including plugins). This requires that
the ForeignKey fields specify the "related_name" attribute (instead of
the "+" placeholder).
  • Loading branch information
pheus committed Jun 21, 2024
1 parent ba74648 commit 8d00390
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions netbox_aci_plugin/models/tenant_app_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ACIAppProfile(NetBoxModel):
nb_tenant = models.ForeignKey(
to="tenancy.Tenant",
on_delete=models.PROTECT,
related_name="+",
related_name="aci_app_profiles",
verbose_name=_("NetBox tenant"),
blank=True,
null=True,
Expand Down Expand Up @@ -129,7 +129,7 @@ class ACIEndpointGroup(NetBoxModel):
nb_tenant = models.ForeignKey(
to="tenancy.Tenant",
on_delete=models.PROTECT,
related_name="+",
related_name="aci_endpoint_groups",
verbose_name=_("NetBox tenant"),
blank=True,
null=True,
Expand Down
8 changes: 4 additions & 4 deletions netbox_aci_plugin/models/tenant_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ class ACIVRF(NetBoxModel):
nb_tenant = models.ForeignKey(
to="tenancy.Tenant",
on_delete=models.PROTECT,
related_name="+",
related_name="aci_vrfs",
verbose_name=_("NetBox tenant"),
blank=True,
null=True,
)
nb_vrf = models.ForeignKey(
to="ipam.VRF",
on_delete=models.PROTECT,
related_name="+",
related_name="aci_vrfs",
verbose_name=_("NetBox VRF"),
blank=True,
null=True,
Expand Down Expand Up @@ -228,7 +228,7 @@ class ACIBridgeDomain(NetBoxModel):
nb_tenant = models.ForeignKey(
to="tenancy.Tenant",
on_delete=models.PROTECT,
related_name="+",
related_name="aci_bridge_domains",
verbose_name=_("NetBox tenant"),
blank=True,
null=True,
Expand Down Expand Up @@ -532,7 +532,7 @@ class ACIBridgeDomainSubnet(NetBoxModel):
nb_tenant = models.ForeignKey(
to="tenancy.Tenant",
on_delete=models.PROTECT,
related_name="+",
related_name="aci_bridge_domain_subnets",
verbose_name=_("NetBox tenant"),
blank=True,
null=True,
Expand Down
2 changes: 1 addition & 1 deletion netbox_aci_plugin/models/tenants.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ACITenant(NetBoxModel):
nb_tenant = models.ForeignKey(
to="tenancy.Tenant",
on_delete=models.PROTECT,
related_name="+",
related_name="aci_tenants",
verbose_name=_("NetBox tenant"),
blank=True,
null=True,
Expand Down

0 comments on commit 8d00390

Please sign in to comment.