Просмотр исходного кода

Retain ip_addresses name for related IPAddress objects

Jeremy Stretch 5 лет назад
Родитель
Сommit
40938f0c8a

+ 1 - 1
netbox/dcim/api/views.py

@@ -484,7 +484,7 @@ class PowerOutletViewSet(CableTraceMixin, ModelViewSet):
 
 class InterfaceViewSet(CableTraceMixin, ModelViewSet):
     queryset = Interface.objects.prefetch_related(
-        'device', '_connected_interface', '_connected_circuittermination', 'cable', 'ipaddresses', 'tags'
+        'device', '_connected_interface', '_connected_circuittermination', 'cable', 'ip_addresses', 'tags'
     ).filter(
         device__isnull=False
     )

+ 1 - 1
netbox/dcim/models/device_components.py

@@ -686,7 +686,7 @@ class Interface(CableTermination, ComponentModel, BaseInterface):
         blank=True,
         verbose_name='Tagged VLANs'
     )
-    ipaddresses = GenericRelation(
+    ip_addresses = GenericRelation(
         to='ipam.IPAddress',
         content_type_field='assigned_object_type',
         object_id_field='assigned_object_id'

+ 1 - 1
netbox/dcim/views.py

@@ -1442,7 +1442,7 @@ class InterfaceView(ObjectView):
 
         # Get assigned IP addresses
         ipaddress_table = InterfaceIPAddressTable(
-            data=interface.ipaddresses.restrict(request.user, 'view').prefetch_related('vrf', 'tenant'),
+            data=interface.ip_addresses.restrict(request.user, 'view').prefetch_related('vrf', 'tenant'),
             orderable=False
         )
 

+ 1 - 1
netbox/ipam/models.py

@@ -2,7 +2,7 @@ import netaddr
 from django.conf import settings
 from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
 from django.contrib.contenttypes.models import ContentType
-from django.core.exceptions import ValidationError, ObjectDoesNotExist
+from django.core.exceptions import ValidationError
 from django.core.validators import MaxValueValidator, MinValueValidator
 from django.db import models
 from django.db.models import F

+ 1 - 1
netbox/virtualization/models.py

@@ -405,7 +405,7 @@ class Interface(BaseInterface):
         blank=True,
         verbose_name='Tagged VLANs'
     )
-    ipaddresses = GenericRelation(
+    ip_addresses = GenericRelation(
         to='ipam.IPAddress',
         content_type_field='assigned_object_type',
         object_id_field='assigned_object_id'

+ 1 - 1
netbox/virtualization/views.py

@@ -306,7 +306,7 @@ class InterfaceView(ObjectView):
 
         # Get assigned IP addresses
         ipaddress_table = InterfaceIPAddressTable(
-            data=interface.ipaddresses.restrict(request.user, 'view').prefetch_related('vrf', 'tenant'),
+            data=interface.ip_addresses.restrict(request.user, 'view').prefetch_related('vrf', 'tenant'),
             orderable=False
         )