djangosnippets.org: Latest snippets tagged with 'ip-address'http://djangosnippets.org/tags/ip-address/2009-07-10T16:54:42.674004-05:00Test IP against IP address+Subnet whitelist
2009-07-10T16:54:42.674004-05:00mtigashttp://djangosnippets.org/snippets/1624/<p>Simple function that tests whether a given IP address is in a list of IP addresses or subnets.
</p>
<p>Requires <code>ipaddr</code>. Comes with Python 2.7 or 3.1, <a href="http://code.google.com/p/ipaddr-py/">downloadable here</a> for earlier versions.
</p>
<p>More info on <code>ipaddr</code> <a href="http://docs.python.org/dev/py3k/library/ipaddr.html">in Python 3.1 docs</a>.
</p>
Freely redistributableTuned IPAddressField with IPv4 & IPv6 support using Postgres Network Field type
2009-04-20T10:31:12.653189-05:00illscihttp://djangosnippets.org/snippets/1453/<p>I wanted to store ipv4 and ipv6 ip's in django but I wanted to use the postgresql inet network field type:</p>
<p>http://www.postgresql.org/docs/8.3/static/datatype-net-types.html</p>
<p>and I wanted to use IPy.py IP objects in python. I followed these very helpful examples along with the django documentation:</p>
<p>http://vaig.be/2009/03/numeric-ip-field-for-django.html
http://www.djangosnippets.org/snippets/1381/</p>
<p>It took me awhile to …</p>
Freely redistributableTuned IPAddressField with IPv4 & IPv6 support
2009-03-20T15:21:59.705446-05:00divermanhttp://djangosnippets.org/snippets/1381/<p>Tuned IPAddressField with IPv4 & IPv6 support</p>
Freely redistributableBlock IP addresses
2008-05-07T17:56:50.633172-05:00pillhttp://djangosnippets.org/snippets/744/<p>I needed a quick and dirty way to block a user from my site. </p>
<p>Just include this middleware class under the 'MIDDLEWARE_CLASSES' variable in your settings.py file.</p>
<p>Also include the variable BLOCKED_IPS = ('123.123.123.123',) variable, where the value is a tuple of IP addresses you want blocked from your site.</p>
Freely redistributable