ipinfo / django Goto Github PK
View Code? Open in Web Editor NEWOfficial Django Library for IPinfo API (IP geolocation and other types of IP data)
Home Page: https://ipinfo.io
License: Apache License 2.0
Official Django Library for IPinfo API (IP geolocation and other types of IP data)
Home Page: https://ipinfo.io
License: Apache License 2.0
After update package ipinfo_django 1.2.0 to 1.3.0, It return me this error:
from ipinfo_django.ip_selector.default import DefaultIPSelector
ModuleNotFoundError: No module named 'ipinfo_django.ip_selector'
...
django.core.exceptions.ImproperlyConfigured: WSGI application 'Backend.wsgi.application' could not be loaded; Error importing module.
I already added 'ipinfo_django.middleware.IPinfo' in MIDDLEWARE
Django 3.0+ is beginning to provide async support: https://docs.djangoproject.com/en/3.1/topics/async/
We will be working on an async interface to our underlying Python library soon: ipinfo/python#25
When it's more clear how Django plans on supporting a fully async request stack, we can utilize the async interface to the Python SDK.
Hello, I am not sure if I am doing everything correctly but once I add the middleware definition for IPInfo in the settings.py
file of my django project, I get the following error message.
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 45, in get_internal_wsgi_application
return import_string(app_path)
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/site-packages/django/utils/module_loading.py", line 17, in import_string
module = import_module(module_path)
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/kevin_tiba/PycharmProjects/animals/animals/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
return WSGIHandler()
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/site-packages/django/core/handlers/wsgi.py", line 135, in __init__
self.load_middleware()
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/site-packages/django/core/handlers/base.py", line 35, in load_middleware
middleware = import_string(middleware_path)
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/site-packages/django/utils/module_loading.py", line 17, in import_string
module = import_module(module_path)
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/site-packages/ipinfo_django/middleware.py", line 3, in <module>
import ipinfo
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/site-packages/ipinfo/__init__.py", line 1, in <module>
from .handler import Handler
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/site-packages/ipinfo/handler.py", line 10, in <module>
from .cache.default import DefaultCache
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/site-packages/ipinfo/cache/default.py", line 6, in <module>
from .interface import CacheInterface
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/site-packages/ipinfo/cache/interface.py", line 6, in <module>
import six
ModuleNotFoundError: No module named 'six'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 137, in inner_run
handler = self.get_handler(*args, **options)
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 27, in get_handler
handler = super().get_handler(*args, **options)
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 64, in get_handler
return get_internal_wsgi_application()
File "/Users/kevin_tiba/miniconda3/envs/django_env/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 50, in get_internal_wsgi_application
) from err
django.core.exceptions.ImproperlyConfigured: WSGI application 'animals.wsgi.application' could not be loaded; Error importing module.
Here is the middleware section:
MIDDLEWARE = [
'ipinfo_django.middleware.IPinfo',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
Hi,
since your update to 2.0.0, the request.ipinfo.ip returns the server public IP instead of the client public IP.
what should I do to get the client public IP like before instead of the server public id?
I really like your API. You are doing an amazing job.
Best regards.
Reproduce:
asgiref<4
and asgiref>=3.4.1
asgiref
past 3.2.1 makes django throw an ipinfo exception: 'IPinfo' object has no attribute '_is_coroutine'
have the following
ip_data = ipinfo.getHandler(self.ipinfo_token, **self.ipinfo_settings)
ip_data = ip_data.getDetails(ip_address)
the following error returns
requests.exceptions.HTTPError: 403 Client Error: Forbidden
``
Originally posted by @jompol63 in #9 (comment)
hello iam getting an attribute error when i try to create a view. i am trying the example code in the README.md file.
I'm using django 3.2.4 and ipinfo correctly parses requests done when testing on a local environment, but not in prod (deployed on google app engine). I assume it has to do with CSP blocking outgoing requests, but i added ipinfo.io
to allowed request URLs, but it still defaults to showing every request as one made from the US (Mountain View). Any ideas?
It's not clear in the docs what would happen if there's an error somewhere in the middleware, i.e. with a bad API key, getting rate limited, etc. We should link to https://docs.djangoproject.com/en/2.2/topics/http/middleware/#exception-handling at least to describe that Django would simply pass an HTTP response with status code 500 back up the middleware stack.
But that behavior is also not too desirable - getting rate limited shouldn't cause the site to respond with 429s or 500s. We should handle error cases gracefully within the middleware and putting that into the request object.
Add an optional IP selection handler to the SDK client initialization step which accepts the request context and expects returning an IP.
The default handler, if no handler is specified by the user, will simply return the IP attached to the request object.
An additional handler should be available within the library, which looks into the X-Forwarded-For
header and gets the first IP in the list if it exists, falling back to the IP attached to the request if the header isn't available. This is an implementation that users can optionally use instead of making their own.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.