Created
May 30, 2019 11:20
-
-
Save walison17/1e6d6f27a8795b219bf078d7c84cade1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_ip_from_request(request): | |
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') | |
if x_forwarded_for: | |
return x_forwarded_for.split(',')[0] | |
return request.META.get('REMOTE_ADDR') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment