Archive | August, 2009

How to Get a Client IP Address in DJANGO

14. August 2009

5 Comments

Here is a small snippet to get the client’s ip address in your python code in DJANGO. You might have tried the ‘REMOTE_ADDR’ key in the request object but it always returns 127.0.0.1. To fix this, you can use the ‘HTTP_X_FORWARDED_FOR’ variable like so: from django.http import HttpRequest def mypage(request): client_address = request.META['HTTP_X_FORWARDED_FOR'] .... The […]

Continue reading...