Answers for "django get ip from request"

1

how to get the user ip in djagno

def get_client_ip(request):
    x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
    if x_forwarded_for:
        ip = x_forwarded_for.split(',')[0]
    else:
        ip = request.META.get('REMOTE_ADDR')
    return ip
Posted by: Guest on September-14-2020
0

get ip address in django

request.META.get("REMOTE_ADDR")
Posted by: Guest on April-26-2021

Code answers related to "django get ip from request"

Python Answers by Framework

Browse Popular Code Answers by Language