Django: What's the correct way to get the requesting IP address?

Posted by swisstony on Stack Overflow See other posts from Stack Overflow or by swisstony
Published on 2010-05-15T13:46:03Z Indexed on 2010/05/15 13:54 UTC
Read the original article Hit count: 235

Filed under:
|
|

I'm trying to develop an app using Django 1.1 on Webfaction. I'd like to get the IP address of the incoming request, but when I use request.META['REMOTE_ADDR'] it returns 127.0.0.1. There seems to be a number of different ways of getting the address, such as using HTTP_X_FORWARDED_FOR or plugging in some middleware called SetRemoteAddrFromForwardedFor. Just wondering what the best approach was?

© Stack Overflow or respective owner

Related posts about django

Related posts about python