How to query Django model defining IP range with 2 int fields (IP, mask)
I have:
class Range(models.Model):
ip = models.IntegerField() # as produced by socket.inet_aton + struct.unpack
mask = models.IntegerField()
Given a specific IP, how can I get all ranges corresponding to that specific IP using Django models?
If I was using raw SQL I would use bitwise database operators, but Django ORM does not support them.
+2
source to share
3 answers