django-ipware
A Django application to retrieve user's IP address
What it is and what it does
django-ipware is a Django wrapper around the python-ipware library that extracts a client's originating IP address from a request object. It handles the complexity of proxy headers—such as X-Forwarded-For, X-Real-IP, and CloudFlare headers—by checking them in a configurable precedence order. The package returns both the IP address and a boolean indicating whether it is publicly routable.
The main use case is in Django views or middleware where you need to log, authenticate, or make decisions based on the client's real IP rather than the immediate request source (which may be a load balancer or reverse proxy). It supports advanced scenarios like trusted proxy lists, proxy count filtering, and custom header precedence orders via Django settings or function parameters. The package explicitly warns that it is not a complete defense against IP spoofing and should be layered with firewall rules and authentication measures.
Use it for:
- Log the real client IP in Django middleware or views when behind a load balancer or CDN.
- Validate client IP against a trusted proxy list to filter spoofed requests in security-sensitive operations.
- Extract originating client IP for rate limiting, geolocation, or fraud detection workflows.
- Configure custom header precedence for non-standard proxy setups (e.g., internal corporate proxies).
- Determine whether a client IP is private or publicly routable for conditional business logic.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Retrieves the client's IP address from a Django request object, handling proxies and multiple header precedence orders to extract the originating client IP.
Yes, if you are running Django behind one or more proxies and need reliable client IP extraction. The package is stable (Production/Stable classifier), supports modern Python versions (3.8–3.12), has no known vulnerabilities, and low install friction. Dormant maintenance is acceptable for a focused, mature utility. Not necessary if your Django app runs without proxies or if you handle IP extraction via your proxy/load balancer configuration.
Install
django-ipware on PyPI
pip
pip install django-ipwareuv
uv add django-ipwarepoetry
poetry add django-ipwareInstalling django-ipware
Before you install
Low friction: pure Python wheel with a single runtime dependency (python-ipware). Maintenance is dormant—last release was 847 days ago, though the repository remains active with 1066 stars and no archived status. Suitable for stable, non-evolving use cases.
License in practice
MIT license is permissive and poses no restrictions on commercial or proprietary use. You may use, modify, and distribute this package freely provided you retain the license notice.
Quickstart
pip install django-ipware
from ipware import get_client_ip
client_ip, is_routable = get_client_ip(request)
if client_ip:
print(f"Client IP: {client_ip}, Routable: {is_routable}")
Requires Django request object; IP spoofing is not prevented—use trusted_proxies_ips or proxy_count parameters to validate against known proxy infrastructure.
Verify before relying
- Exact behavior differences between django-ipware and its underlying dependency python-ipware beyond the wrapper layer.
- Performance characteristics when handling requests with many proxy headers or large header lists.
- Whether dormant maintenance status indicates sufficient stability for new projects or signals deprecation risk.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — python-ipware |
| Maintenance | dormant — 847 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 5,884,830/month — #2,017 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_ipware-7.0.1-py2.py3-none-any.whl
Tags
More WWW/HTTP packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
h11h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
httpxHTTPX is a fully featured HTTP client library…
permissive · top 100 on PyPI
httpcoreA minimal low-level HTTP client library that…
permissive · top 100 on PyPI
aiohttpaiohttp is an async HTTP client and server…
permissive · top 100 on PyPI
django-xffDjango middleware that extracts the real client…
permissive · top 15,000 on PyPI
proxy-protocolParses and handles the PROXY protocol (v1 and…
permissive · top 5,000 on PyPI
python-ipwareExtracts a client's IP address from web request…
permissive · top 5,000 on PyPI
django-revproxyA Django application that forwards HTTP…
copyleft · top 15,000 on PyPI
proxyprovidersProvides a unified Python interface for…
permissive · top 15,000 on PyPI
django-cors-headersAdds Cross-Origin Resource Sharing (CORS)…
permissive · top 1,000 on PyPI
vercel-headersRegisters and exposes request headers for…
permissive · top 5,000 on PyPI
django-axesdjango-axes tracks failed login attempts to…
permissive · top 5,000 on PyPI
django-netfieldsProvides Django model fields for PostgreSQL…
permissive · top 15,000 on PyPI
iptoolsProvides utilities for parsing, validating, and…
permissive · top 15,000 on PyPI