Simple return user's real IP address in Django
pip install django-ip
# Need Setting
request.client_ip
# Not Need Setting
from ipaddr import client_ip
def xxx(request):
ipaddr = client_ip(request)
# Use `MIDDLEWARE_CLASSES` prior to Django 1.10
MIDDLEWARE = (
...
'ipaddr.middleware.IPAddrMiddleware',
...
)