1

I am developing a project that need to store user's last using location, For that i have done like below

the below code from stackoverflow source

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

Here i am getting the user machine ip address(192.xxx.x.xx) not public ip(115.xxx.xxx.xx).How can i get the public address(network provider given).Thanks in advance

Community
  • 1
  • 1
Mulagala
  • 8,231
  • 11
  • 29
  • 48

0 Answers0