Created
May 21, 2014 21:06
-
-
Save jaytaylor/a7f74459a891fbc234d4 to your computer and use it in GitHub Desktop.
Django + Postgres CIDR filtering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ip_column_name = 'ip' | |
keyword = '63.0.0.0/24' | |
where = '{}::inet << %s::inet::cidr'.format(ip_column_name) | |
match = MyDjangoModel.objects.all() | |
match = match.extra(where=[where], params=[keyword]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment