Python/Django get country flag from IP
Personally I would set a generic flag as a fallback (django flag perhaps?) if user does not set their country, and to be fair there must be a reason if user doesn't. Or you can simply make that country field mandatory.
And assuming that person in that country based on their existing IP just doesn't sound right.
Imagine if you are working remotely via VPN or behind a proxy server... you get the idea.
It makes more sense if you just want to redirect people to sub-domain (different language) site base on IP.
I am using django-countries to get a flag from the CountryField and it works. However, some users don't have a country set on their profiles, but I still have to display a flag. My idea was to get a country from IP and then get a flag from the country or anything similar to that.
Unfortunately, this is not happening in the view, so I don't have the request. I can set the IP in the template and then, in the backend, check if no flag was found (if a country is not provided) and then somehow use the IP that I got from the template to get a flag. Is something like that possible? If needed, GeoDjango is already included in the project.
Perhaps there is a totally different way of doing this, but I am new to Django and still learning. Thanks.