0

In my webapp I was getting the IP address of the user system and showing the same in the landing page. However for testing when I am making a request from all my devices at home I see same IP address(49.37.71.31).

2 questions

  1. Why is this happening
  2. How can I uniquely identify the machine which is making the request to my web app.

index.html

<div class="button add-list-button">
    <a href="javascript:void(0)" class="btn">{{ ip }}</a>
</div>

views.py

def index(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 render(request, 'index.html', context = {'ip':ip})
Himanshu Poddar
  • 7,112
  • 10
  • 47
  • 93
  • Does this answer your question? [How do I get user IP address in django?](https://stackoverflow.com/questions/4581789/how-do-i-get-user-ip-address-in-django) – Mate May 04 '22 at 14:19
  • Nope, please read the question is why all my devices are showinng same IP adress i my webapp – Himanshu Poddar May 04 '22 at 14:22

0 Answers0