djangosnippets.org: Latest snippets tagged with 'country'http://djangosnippets.org/tags/country/2019-06-26T07:19:45.268959-05:00Geoip middleware to restrict users to a set of allowed countries
2019-06-26T07:19:45.268959-05:00pakalhttp://djangosnippets.org/snippets/10675/<p>This middleware uses Django's Geoip support (https://docs.djangoproject.com/fr/2.2/ref/contrib/gis/geoip2/), as well as axes's package helper to retrieve IP address (since Django's REMOTE_ADDR might be wrong when behind a reverse proxy).</p>
<p>Ensure your geolite DB files are up to date (eg. with https://djangosnippets.org/snippets/10674/).</p>
<p>The checker is optional, but ensures that security is not …</p>
Freely redistributableJSON fixtures of Intl. country codes & dial-codes
2010-08-16T12:46:55.073413-05:00dibau_naum_hhttp://djangosnippets.org/snippets/2150/<p>Just a dump of a countries data, including standard codes & dial-codes, based on the following model:
- Country
-- name : CharField
-- code : CharField
-- dial_code : CharField
</p>
<p>Note that countries aren't unique, as some may have several intl. dial codes.
</p>
<p>You can parse it using script …</p>
Freely redistributableCountryField (ISO 3166-1)
2009-04-29T05:17:54.011663-05:00dougalhttp://djangosnippets.org/snippets/1476/<p>List of countries based on the ISO 3166-1 standard.</p>
<p>List adapated from http://opencountrycodes.appspot.com/python/</p>
<p>This is useful for certain services such as Protx that requires countries in the two letter standard.</p>
Freely redistributableCountryField (UN Country List, 3 Char Codes)
2009-01-12T08:11:07.686291-06:00djmhttp://djangosnippets.org/snippets/1281/<p><strong>Adapted from</strong> <a href="http://www.djangosnippets.org/snippets/494/">CountryField</a> - <strong>Initial thanks to marinho</strong></p>
<p>Uses the UN country list listed in the source - this provides the 3 character ISO country code.
Ordered by display value and not country code.</p>
<p>Just place anywhere you like and import CountryField to use.</p>
<p><code>country = CountryField(verbose_name="Country", help_text="The registrant's country …</code></p>
Freely redistributableCountryField
2007-12-01T07:40:17.463873-06:00marinhohttp://djangosnippets.org/snippets/494/<p><strong>How to use</strong> put this code somewhere you want, import CountryField and use</p>
Freely redistributable