get country from IP_addres.

69 views
Skip to first unread message

Amor Zamora

unread,
Dec 15, 2021, 9:08:53 PM12/15/21
to django...@googlegroups.com
Can you help me?
I need to obtain the country of where the users access from the IP and insert that information into the sqlite3 database.

Little description.
I have an application that I have to do the statistics and insert into the sqlite3 database, the IP information, the country from which it is accessed, who generates the information and how many times has clicked on the application.
Question 1 is that I cannot find any suitable module in DJango that allows me to combine the information described above.
I am using. IP_address, os, daemonize and socket and I don't quite realize how to get the country from where it is accessed.
Thanks

--
Amor Zamora
Behind the distance, 
your mouth and mine hide, 
complices of a kiss, caresses, fantasies, 
distance as close as the sky and the sea, 
my piece is in your bed, in mine, is your love.
Behind the distance hide love, memories, 
encounters, experiences, circumstances, pain and good times, 
it is after her, the distant ones, 
that we leave feelings, 
but if we really miss, 
distance,
it is only your time.

Michael Thomas

unread,
Dec 15, 2021, 9:30:58 PM12/15/21
to django...@googlegroups.com
The geoip2 python package will help you get location information from the the IP.
Inserting the data into a database via the ORM is fairly straight forward. If you haven't worked with the ORM yet, this part of the django tutorial should get you pointed in the right direction:

Kind Regards,
Michael Thomas

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKMTbHXbM4QFh5kRiShsroObKjefGzvRchX5m3S2ps6M95bwgQ%40mail.gmail.com.

Amor Zamora

unread,
Dec 15, 2021, 9:39:40 PM12/15/21
to django...@googlegroups.com
Thank you very much I review it and let you know if it served me.

fahad ahmad

unread,
Dec 16, 2021, 11:27:25 AM12/16/21
to django...@googlegroups.com
There are geoip databases you can download or use api services such as: https://ipgeolocation.io/ to get the information. 



--

Agoua David

unread,
Dec 16, 2021, 6:51:23 PM12/16/21
to django...@googlegroups.com
Hi 

I think you should use an API to fetch the country and some other information about you users
Many site provide a way to get the country of an IP address through an api

--

Come Now

unread,
Dec 23, 2021, 9:25:06 AM12/23/21
to django...@googlegroups.com

--

Bernard Mallala

unread,
Dec 23, 2021, 10:11:33 AM12/23/21
to Django users
In line with prior examples by others, take a look at this complete example leveraging GeoIP2

Get Visitor Location using GeoIP2 in Django
Reply all
Reply to author
Forward
0 new messages