expephalon/core/helpers/request.py

7 lines
No EOL
219 B
Python

def get_client_ip(request):
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
if x_forwarded_for:
return x_forwarded_for.split(',')[0]
else:
return request.META.get('REMOTE_ADDR')