Tuesday, May 4, 2021
Get user IP address in Django
def get_client_ip(request):
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
if x_forwarded_for:
ip = x_forwarded_for.split(',')[-1].strip()
else:
ip = request.META.get('REMOTE_ADDR')
return ip
0 Response to Get user IP address in django
Comments are personally moderated by our team. Promotions are not encouraged.
Post a Comment