#NEWLINE# def get_client_ip( request ) : #NEWLINE# #INDENT# '\n    Given an HTTP request, returns the related IP address.\n    ' #NEWLINE# x_forwarded_for = request . META . get ( 'HTTP_X_FORWARDED_FOR' , None ) #NEWLINE# if x_forwarded_for : #NEWLINE# #INDENT# ip = x_forwarded_for . split ( ',' ) [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ip = request . META . get ( 'REMOTE_ADDR' ) #NEWLINE# #UNINDENT# return ip