django-client-ip is a Django middleware that retrieves the client IP address and optionally fetches geolocation data using ip-api.com.
- Install the package using pip:
pip install django-client-ip- Add the middleware to your Django project in settings.py:
MIDDLEWARE = [
# Other middlewares
'django_client_ip.GetClientIP',
]Once installed, every request object will have a client_ip attribute containing the IP address and geolocation data (if available).
