expephalon/core/helpers/request.py

7 lines
219 B
Python
Raw Normal View History

2020-05-23 13:30:21 +00:00
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')