Saturday, September 26, 2020

Re: capture client side location in Django

Hi all,

I tried use https://docs.djangoproject.com/en/3.1/ref/contrib/gis/geoip2/ and This particular package requires 
GeoLite2-Country.mmdb.gz 
GeoLite2-City.mmdb.gz  
These databases are not free. We are looking for an open source API or package for our web application. 

I appreciate if someone can share suitable pointers.

Thanks
~Salima


On Fri, Sep 25, 2020 at 2:48 AM Kasper Laudrup <laudrup@stacktrace.dk> wrote:
On 25/09/2020 06.10, Stats Student wrote:
> You can read the client's IP address with -
>
> request.META['REMOTE_ADDR']  -- ( not sure how it handles proxies, etc )
>

Proxies should set the X-Forwarded-For header:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For

the value of which will then be used in the META dictionary.

Worth noticing that it's trivially possible for any client to set that
header as well and there's no way to reliably get the actual IP address
of the client simply because of how HTTP works.

Of course that's just a variation of "never trust the client" :-)

Kind regards,

Kasper Laudrup

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c5aedd33-9611-0624-2dd4-7d3589b03c7d%40stacktrace.dk.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMSz6bnu_soSSbdqPQTqB%3Dw9PNkpzOY620t0x0gCFZ7qKhkJKg%40mail.gmail.com.

No comments:

Post a Comment