#NEWLINE# def choice_from_param( self , param ) : #NEWLINE# #INDENT# if ( param is None ) : #NEWLINE# #INDENT# return self . field_obj . to_python ( param ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# choice_pk = super ( ForeignKeyFilter , self ) . choice_from_param ( param ) #NEWLINE# lookup = { #NEWLINE# #INDENT# self . rel_field . name : choice_pk , #NEWLINE# #UNINDENT# } #NEWLINE# try : #NEWLINE# #INDENT# obj = self . rel_model . objects . get ( ** lookup ) #NEWLINE# #UNINDENT# except self . rel_model . DoesNotExist : #NEWLINE# #INDENT# raise ValueError ( 'object does not exist in DB' ) #NEWLINE# #UNINDENT# return obj