Django hook (Middleware and Decorator) to geolocate visitors using their IP address
Project description
Django Ip Geolocation:
Django request/response hooks to geolocate visitors by their ip address
Usage:
Decorator:
Use decorators to decorate views :
from django_ip_geolocation.decorators import with_ip_geolocation
@with_ip_geolocation
def api_view(request):
location = request.location
...
Middleware:
First you need to add the middleware into your settings.py
MIDDLEWARE = [
...
'django_ip_geolocation.middleware.IpGeolocationMiddleware',
...
]
Then the location is available to all views in request and response:
def api_view(request):
location = request.location
...
def other_view(request):
location = request.location
...
Settings
You can configure backend for your hook in the settings.py
as follow:
GEOLOCATION_BACKEND = 'django_ip_geolocation.backends.IPGeolocationAPI'
Available Backends:
django_ip_geolocation.backends.IPGeolocationAPI
: (Default) Using https://ipgeolocationapi.com/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for django-ip-geolocation-0.0.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cc23f7474b4eac9e0669403bb826b5a10373703a4af37655ae297b9c6197bd8 |
|
MD5 | 2e25259f2c6bc2dd19b643cf79f55658 |
|
BLAKE2b-256 | 7bd085710b2d0dd1d901ea2bb410dc18f2ca998191611364bedd15787ba58eee |