def x_forwarded_ip(request):
 ip_address_list = request.META.get('HTTP_X_FORWARDED_FOR')
 if ip_address_list:
  ip_address_list = ip_address_list.split(',')
  return ip_address_list[0]

def x_forwarded_ip ( request ) : ip_address_list = request . META . get ( 'HTTP_X_FORWARDED_FOR' ) if ip_address_list : ip_address_list = ip_address_list . split ( ',' ) return ip_address_list [ 0 ]
returns the ip address contained in the http_x_forwarded_for header .