{"id":1997,"library":"django-ipware","title":"Django IPware","description":"A Django application to retrieve a user's IP address. It aims to provide the best attempt to get the client's IP while handling scenarios involving proxy servers and load balancers. `django-ipware` is a wrapper using `python-ipware` under the hood since version 6.0.0. The current version is 7.0.1, released on April 19, 2024, indicating active development and a regular release cadence with updates to align with new Django and Python versions.","status":"active","version":"7.0.1","language":"en","source_language":"en","source_url":"https://github.com/un33k/django-ipware","tags":["django","ip address","middleware","security","network","client"],"install":[{"cmd":"pip install django-ipware","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core logic for IP address resolution; `django-ipware` is a wrapper around `python-ipware` since version 6.0.0.","package":"python-ipware","optional":false},{"reason":"Django web framework integration.","package":"Django","optional":false}],"imports":[{"note":"The main function `get_client_ip` is directly importable from the `ipware` module, not `django_ipware`.","wrong":"from django_ipware import get_client_ip","symbol":"get_client_ip","correct":"from ipware import get_client_ip"}],"quickstart":{"code":"from django.http import HttpRequest, JsonResponse\nfrom ipware import get_client_ip\n\ndef my_view(request: HttpRequest):\n    client_ip, is_routable = get_client_ip(request)\n\n    if client_ip is None:\n        # Unable to get the client's IP address\n        return JsonResponse({'error': 'Unable to determine client IP'}, status=400)\n    else:\n        # We got the client's IP address\n        ip_info = {\n            'ip_address': str(client_ip),\n            'is_publicly_routable': is_routable\n        }\n        return JsonResponse(ip_info)","lang":"python","description":"A simple Django view demonstrating how to retrieve the client's IP address using `get_client_ip`. It returns the IP address and a boolean indicating if it's publicly routable. Remember to pass the `request` object."},"warnings":[{"fix":"Implement additional security measures (firewalls, WAFs) and utilize `proxy_trusted_ips` or `proxy_count` arguments if behind known proxies to improve accuracy. Always validate IP addresses for security-critical operations.","message":"There is no perfect out-of-the-box solution against IP Address Spoofing. `django-ipware` makes the best attempt but should be used only as a complement to other firewall and security measures.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review `django-ipware` and `python-ipware` documentation for specific API changes if upgrading from versions older than 6.0.0, especially if customizing IP resolution logic beyond basic `get_client_ip` calls. Ensure `python-ipware` is considered a core dependency for recent versions.","message":"Prior to version 6.0.0, `django-ipware` was a standalone package. From version 6.0.0 onwards, it became a wrapper around the `python-ipware` package. While the primary `get_client_ip` import path remains stable, internal workings and advanced configurations (especially for direct `python-ipware` usage) might differ.","severity":"breaking","affected_versions":">= 6.0.0"},{"fix":"If your Django server is behind proxies, configure `get_client_ip(request, proxy_count=N)` with the correct number of proxies or `get_client_ip(request, proxy_trusted_ips=['IP_1', 'IP_2'])` with known trusted proxy IP ranges. Customize `IPWARE_META_PRECEDENCE_ORDER` in settings if non-standard HTTP headers are used.","message":"Incorrect IP address resolution behind proxy servers (e.g., load balancers, CDNs). Without proper configuration, `django-ipware` might return the proxy's IP address instead of the actual client's IP.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If using `django-ipware` with `django-axes` or similar packages, ensure `django-ipware` is explicitly installed (`pip install django-ipware`) and review the integrating library's documentation for updated configuration settings (e.g., `AXES_IPWARE_PROXY_ORDER` instead of `AXES_PROXY_ORDER` in `django-axes`).","message":"Some integrating packages (e.g., `django-axes` versions 6+) have made `django-ipware` an optional dependency and renamed their internal settings related to IPware. This indicates a shift towards more explicit dependency management and configuration in ecosystem partners.","severity":"deprecated","affected_versions":"From `django-axes` v6 onwards (affects users integrating with `django-axes`)"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}