Last active
March 26, 2018 07:51
-
-
Save hwshim0810/7645367fa460ac46f836508d211de695 to your computer and use it in GitHub Desktop.
get ip in django
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_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') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment