P
P
PiggyPig2018-02-20 16:43:23
Django
PiggyPig, 2018-02-20 16:43:23

How to deal with dynamic IPs (Django)?

There is the following function:

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

The IP is determined and everything seems to be fine, but when the mobile Internet is turned on again, the IP is updated (at least for me).
Is it possible to somehow supplement the function or add some additional identifier from the side (data from the device or browser, for example)?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question