Skip to content

Instantly share code, notes, and snippets.

@csarcom
Created April 30, 2013 16:09
Show Gist options
  • Save csarcom/5489714 to your computer and use it in GitHub Desktop.
Save csarcom/5489714 to your computer and use it in GitHub Desktop.
def queryset(self, request):
qs = super(NetworksAdmin, self).queryset(request)
try:
ip = request.GET['q']
tmp = ipaddr.IPAddress(ip).packed
qs = qs.filter(netmin__lte=ip, netmax__gte=ip)
#print len(qs)
for q in qs:
print q
print q.netmin
print q.netmax
print q.country
print q.region
print '####################'
except Exception, e:
pass
return qs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment