Login

Tag "country"

Snippet List

Geoip middleware to restrict users to a set of allowed countries

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). Ensure your geolite DB files are up to date (eg. with https://djangosnippets.org/snippets/10674/). The checker is optional, but ensures that security is not broken due to a misspelled/missing GEOIP_COUNTRY_WHITELIST.

  • middleware
  • ip
  • country
  • geoip
  • restriction
  • blocker
Read More

JSON fixtures of Intl. country codes & dial-codes

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 Note that countries aren't unique, as some may have several intl. dial codes. You can parse it using script or load it using the loaddata command.

  • json
  • fixtures
  • data
  • country
  • countries
  • codes
  • dial_codes
  • international
Read More

CountryField (ISO 3166-1)

List of countries based on the ISO 3166-1 standard. List adapated from http://opencountrycodes.appspot.com/python/ This is useful for certain services such as Protx that requires countries in the two letter standard.

  • field
  • country
  • custom-field
  • iso-3166-1
  • protx
Read More

CountryField (UN Country List, 3 Char Codes)

**Adapted from** [CountryField](http://www.djangosnippets.org/snippets/494/) - **Initial thanks to marinho** 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. Just place anywhere you like and import CountryField to use. `country = CountryField(verbose_name="Country", help_text="The registrant's country of residence.")`

  • forms
  • form
  • field
  • list
  • country
  • countries
  • custom
  • custom-field
  • countryfield
  • countrys
Read More
Author: djm
  • 1
  • 1

CountryField

**How to use** put this code somewhere you want, import CountryField and use

  • field
  • country
  • countries
Read More

5 snippets posted so far.