Monday, January 6, 2020

Re: JSONDecodeError

or another way django httpxforwardedfor module.
Nice.

On Mon, Jan 6, 2020, 22:56 Integr@te System <datacentralize@gmail.com> wrote:
Hi,

Maybe your module requests not present sufficient and check requests api module to use.


On Mon, Jan 6, 2020, 20:20 Yash Garg <gargyash512@gmail.com> wrote:
JSONDecodeError
Exception Value:
Expecting value: line 1 column 1 (char 0)

why i'm getting this error?

views.py-

ip_address = request.META.get('HTTP_X_FORWARDED_FOR', '')
response = requests.get('http://freegeoip.net/json/%s' % ip_address)
geodata = json.loads(response)
print(geodata['ip'])
print(geodata['country_name'])
print(geodata['latitude'])
print(geodata['longitude'])

--
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/34b7736d-f946-451b-b83b-de72d3329da0%40googlegroups.com.

--
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/CAP5HUWpv-RfgPCkRspNAdzm4Qxpy2Za3hpjjmO2qADEQK0opvg%40mail.gmail.com.

No comments:

Post a Comment