Django: Get remote IP address inside settings.py

Posted by Silver Light on Stack Overflow See other posts from Stack Overflow or by Silver Light
Published on 2010-06-16T07:27:45Z Indexed on 2010/06/16 10:52 UTC
Read the original article Hit count: 271

Filed under:
|

Hello!

I want to enable debug (DEBUG = True) For my Django project only if it runs on localhost. How can I get user IP address inside settings.py? I would like something like this to work:

#Debugging only on localhost
if user_ip = '127.0.0.1':
    DEBUG = True
else:
    DEBUG = False 

How do I put user IP address in user_ip variable inside settings.py file?

© Stack Overflow or respective owner

Related posts about python

Related posts about django