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

Fixes #285: Added PREFER_IPV4 configuration setting

This commit is contained in:
Jeremy Stretch
2016-07-13 11:15:37 -04:00
parent e19ce043d6
commit f1b6f0cfee
4 changed files with 17 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
from collections import OrderedDict
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.core.validators import MinValueValidator
@@ -713,7 +714,9 @@ class Device(CreatedUpdatedModel):
@property
def primary_ip(self):
if self.primary_ip6:
if settings.PREFER_IPV4 and self.primary_ip4:
return self.primary_ip4
elif self.primary_ip6:
return self.primary_ip6
elif self.primary_ip4:
return self.primary_ip4