def get_ip_address(request):
"""
获取ip地址
:param request:
:return:
"""
ip = request.META.get("HTTP_X_FORWARDED_FOR", "")
if not ip:
ip = request.META.get('REMOTE_ADDR', "")
client_ip = ip.split(",")[-1].strip() if ip else ""
return client_ip
网友评论