python - django (request 获取 访问者的 IP)

使用 Django 获取访问者的 IP

if request.META.get('HTTP_X_FORWARDED_FOR'):
    ip = request.META.get("HTTP_X_FORWARDED_FOR")
else:
    ip = request.META.get("REMOTE_ADDR")

print("ip : ", ip)

猜你喜欢

转载自www.cnblogs.com/chaoqi/p/10929124.html