Skip to content

Replace django-ipware with python-ipware #7

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pytracking/django.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.conf import settings
from django.http import HttpResponseRedirect, Http404, HttpResponse
from django.views.generic import View
from ipware import get_client_ip
from ipware.ipware import IpWare
from pytracking.tracking import get_configuration, TRACKING_PIXEL, PNG_MIME_TYPE


Expand Down Expand Up @@ -103,8 +103,8 @@ def get_request_data(request):
the client IP in X-Forwarded-For header).
"""
user_agent = request.META.get("HTTP_USER_AGENT")
ip = get_client_ip(request)[0]
return {"user_agent": user_agent, "user_ip": ip}
ip = IpWare().get_client_ip(request.META)[0]
return {"user_agent": user_agent, "user_ip": str(ip)}


def get_configuration_from_settings(settings_name="PYTRACKING_CONFIGURATION"):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"webhook": ["requests>=2.10.0"],
"html": ["lxml>=4.4.0"],
"crypto": ["cryptography>=2.0.0"],
"django": ["django-ipware>=2.0.0", "django>=1.11"],
"django": ["python-ipware>=0.9.0", "django>=1.11"],
}

ALL_REQUIRE = list(chain(*EXTRA_REQUIRES.values()))
Expand Down
2 changes: 1 addition & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ pytest-django
requests>=2.10.0
lxml>=4.4.0
cryptography>=2.0.0
django-ipware>=2.0.0
python-ipware==0.9.0
2 changes: 0 additions & 2 deletions tests/test_django.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

DEFAULT_ENCODED_URL_TO_TRACK = "https://www.bob.com/hello-world/?token=value%C3%A9%C3%A9%C3%A9"

import ipware # noqa

# Must call configure before importing tracking_django
from django.conf import settings
from django.http import Http404
Expand Down