djangosnippets.org: Latest snippets tagged with 'cidr'https://djangosnippets.org/tags/cidr/2010-03-17T09:59:15.740395-05:00IPAddressField with CIDR support
2010-03-17T09:59:15.740395-05:00SeniorHuevohttps://djangosnippets.org/snippets/1961/<p>Based on #1381</p>
<p>Use this piece of code to add IPv4/IPv6 and network support to Django.</p>
<p>An IPAddressField allows you to find IP's for a given subnet. An IPNetworkField allows you to find a subnet for a given IP or find a subnet within a subnet.</p>
<p>For starters, simply paste …</p>
Freely redistributableSupport IP ranges in INTERNAL_IPS
2010-01-09T18:28:11.151972-06:00jdunckhttps://djangosnippets.org/snippets/1862/<p>CIDR ( http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing ) is a well-known IP range syntax. This CIDR_LIST class can be used to make ranges of IPs considered "internal" for Django's debugging and security purposes. (Django only ever needs to do "ip in INTERNAL_IPS" so <strong>contains</strong> is sufficient for the purpose.)
</p>
<p>For example, to make localhost …</p>
Freely redistributableInclude entire networks in INTERNAL_IPS setting
2009-03-10T12:13:50.250358-05:00pmclanahanhttps://djangosnippets.org/snippets/1362/<p>A simple addition to the settings.py file of your project to allow you to easily specify entire network ranges as internal. This is especially useful in conjunction with other tools such as the <a href="http://github.com/robhudson/django-debug-toolbar/tree/master">Django Debug Toolbar</a>.</p>
<p>After you set this up, the following test should pass</p>
<pre><code>test_str = """ …</code></pre>
Freely redistributable