mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-20 02:06:42 -06:00
Remove dependency on RawSQL from IPAddress manager
This commit is contained in:
parent
7a53e24f97
commit
1130f6b9f0
@ -154,10 +154,24 @@ class NetHostContained(Lookup):
|
|||||||
return 'CAST(HOST(%s) AS INET) << %s' % (lhs, rhs), params
|
return 'CAST(HOST(%s) AS INET) << %s' % (lhs, rhs), params
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Transforms
|
||||||
|
#
|
||||||
|
|
||||||
class NetMaskLength(Transform):
|
class NetMaskLength(Transform):
|
||||||
lookup_name = 'net_mask_length'
|
|
||||||
function = 'MASKLEN'
|
function = 'MASKLEN'
|
||||||
|
lookup_name = 'net_mask_length'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def output_field(self):
|
def output_field(self):
|
||||||
return IntegerField()
|
return IntegerField()
|
||||||
|
|
||||||
|
|
||||||
|
class Host(Transform):
|
||||||
|
function = 'HOST'
|
||||||
|
lookup_name = 'host'
|
||||||
|
|
||||||
|
|
||||||
|
class Inet(Transform):
|
||||||
|
function = 'INET'
|
||||||
|
lookup_name = 'inet'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models.expressions import RawSQL
|
|
||||||
|
from ipam.lookups import Host, Inet
|
||||||
|
|
||||||
|
|
||||||
class IPAddressManager(models.Manager):
|
class IPAddressManager(models.Manager):
|
||||||
@ -13,4 +14,4 @@ class IPAddressManager(models.Manager):
|
|||||||
IP address as a /32 or /128.
|
IP address as a /32 or /128.
|
||||||
"""
|
"""
|
||||||
qs = super().get_queryset()
|
qs = super().get_queryset()
|
||||||
return qs.annotate(host=RawSQL('INET(HOST(ipam_ipaddress.address))', [])).order_by('family', 'host')
|
return qs.order_by('family', Inet(Host('address')))
|
||||||
|
Loading…
Reference in New Issue
Block a user