django 获取客户端 ip
def get_client_ip(request): x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') if x_forwarded_for: ip = x_forwarded_for.split(',')[0] # 所以这里是真实的ip else: ip = request.META.get('REMOTE_ADDR') # 这里获得代理ip return ip
request django的请求