[Python] django获得用户ip地址 →→→→→进入此内容的聊天室

来自 , 2019-10-29, 写在 Python, 查看 109 次.
URL http://www.code666.cn/view/107030ca
  1. def get_client_ip(request):
  2.     x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
  3.     if x_forwarded_for:
  4.         ip = x_forwarded_for.split(',')[-1].strip()
  5.     else:
  6.         ip = request.META.get('REMOTE_ADDR')
  7.     return ip
  8. #//python/7276

回复 "django获得用户ip地址"

这儿你可以回复上面这条便签

captcha