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
- Why is this happening
- 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})