Skip to main content

[![Latest Version](https://pypip.in/v/django-country-blocker/badge.png)](https://pypi.python.org/pypi/django-country-blocker/) [![Downloads](https://pypip.in/d/django-country-blocker/badge.png)](https://pypi.python.org/pypi/django-country-blocker/)

django-country-blocker

Django app introducing a Context Processor that adds users location information to the context.

To activate, add country_block.context_processors.addgeoip to your CONTEXT_MODIFIERS. This will give you a user_country variable in your context and a country variable in the user’s session with the user’s 2 character ISO country code, and an in_country boolean set to True is the country matches one of the allowed countries.

Local Settings options

LOCATION : a unique 2 char string that identifies the server’s location

COUNTRY_BLOCK_DEBUG_COUNTRY : sets the user_country equal to this value for all users, letting you test as if you are in this country. False by default.

COUNTRY_BLOCK_DEBUG_REGION : sets the region_code equal to this value for all users, letting you test as if you are in this region. False by default.

Database Settings options (country_block.Settings model)

location : This is a unique 2 char value that corresponds to the LOCATION value in the local settings

free_geo_ip_enabled : Use the freegeoip.net to determine the geography of the user’s IP

free_geo_ip_timeout : freegeoip.net request timeout in seconds (default is 2 seconds)

maxmind_enabled : Use the https://geoip.maxmind.com/a service to determine the geography of the user’s IP. If this is True and free_geo_ip_enabled is also True, the context processor will try the freegeoip.net service first and will only try the Maxmind service if freegeoip.net fails.

maxmind_timeout : maxmind.com request timeout in seconds (default is 6 seconds)

maxmind_local_db_enabled : Use a local Maxmind database instead of the https://geoip.maxmind.com/a service. Must also have maxmind_enabled set to True.

allowed_countries : A M2M relationship of all Countrys that are allowed for the server’s location

staff_user_country : The Country that all django staff users will be assigned

local_ip_user_country : The Country that all local IP users will be assigned

maxmind_license_key : The license key for the Maxmind service. A value is required if maxmind_enabled is True and maxmind_local_db_enabled is False. This gets sent over as the ‘l’ parameter in the payload to the https://geoip.maxmind.com/a service.

Metadata

Release files for django-country-blocker 1.1.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-country-blocker 1.1.13
File Size Uploaded Provenance Actions
django-country-blocker-1.1.13.tar.gz 12.0 kB Without provenance Details for django-country-blocker-1.1.13.tar.gz

Release files / django-country-blocker-1.1.13.tar.gz

Download URL django-country-blocker-1.1.13.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cc4b8a01b98bfc74e18275f07face29894c3715643b7b5d5015918e0a18fd6b7
BLAKE2b-256 checksum
How to use checksums
3553e5e3d0e565b7fd728a39aa181613b8b49c984f08cb8bfa4af79f54cd401b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-country-blocker 1.1.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page