1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Remove "primary for" references to Device on IPAddress

This commit is contained in:
jeremystretch
2021-11-17 12:50:46 -05:00
parent 424ac29131
commit a000ded350
3 changed files with 27 additions and 8 deletions

View File

@ -0,0 +1,23 @@
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('ipam', '0053_asn_model'),
('dcim', '0142_rename_128gfc_qsfp28'),
]
operations = [
migrations.AlterField(
model_name='device',
name='primary_ip4',
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='ipam.ipaddress'),
),
migrations.AlterField(
model_name='device',
name='primary_ip6',
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='ipam.ipaddress'),
),
]

View File

@ -540,7 +540,7 @@ class Device(PrimaryModel, ConfigContextModel):
primary_ip4 = models.OneToOneField(
to='ipam.IPAddress',
on_delete=models.SET_NULL,
related_name='primary_ip4_for',
related_name='+',
blank=True,
null=True,
verbose_name='Primary IPv4'
@ -548,7 +548,7 @@ class Device(PrimaryModel, ConfigContextModel):
primary_ip6 = models.OneToOneField(
to='ipam.IPAddress',
on_delete=models.SET_NULL,
related_name='primary_ip6_for',
related_name='+',
blank=True,
null=True,
verbose_name='Primary IPv6'

View File

@ -523,9 +523,7 @@ class PrefixIPAddressesView(generic.ObjectView):
def get_extra_context(self, request, instance):
# Find all IPAddresses belonging to this Prefix
ipaddresses = instance.get_child_ips().restrict(request.user, 'view').prefetch_related(
'vrf', 'primary_ip4_for', 'primary_ip6_for'
)
ipaddresses = instance.get_child_ips().restrict(request.user, 'view').prefetch_related('vrf')
# Add available IP addresses to the table if requested
if request.GET.get('show_available', 'true') == 'true':
@ -604,9 +602,7 @@ class IPRangeIPAddressesView(generic.ObjectView):
def get_extra_context(self, request, instance):
# Find all IPAddresses within this range
ipaddresses = instance.get_child_ips().restrict(request.user, 'view').prefetch_related(
'vrf', 'primary_ip4_for', 'primary_ip6_for'
)
ipaddresses = instance.get_child_ips().restrict(request.user, 'view').prefetch_related('vrf')
# Add available IP addresses to the table if requested
# if request.GET.get('show_available', 'true') == 'true':