#NEWLINE# def validate_address( self , value ) : #NEWLINE# #INDENT# if ( ( value is None ) or ( isinstance ( self , str ) and ( len ( value ) == 0 ) ) ) : #NEWLINE# #INDENT# if self . context . get ( 'address' ) : #NEWLINE# #INDENT# value = self . context [ 'address' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# value = self . _get_client_ip ( ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not validate_ipaddr ( value ) ) : #NEWLINE# #INDENT# raise serializers . ValidationError ( 'Invalid IP address' ) #NEWLINE# #UNINDENT# return value