def get_object(model, **kwargs):
 for value in kwargs.values():
  if (not value):
   return None
 the_object = model.objects.filter(**kwargs)
 if (len(the_object) == 1):
  the_object = the_object[0]
 else:
  the_object = None
 return the_object

def get_object ( model , ** kwargs ) : for value in kwargs . values ( ) : if ( not value ) : return None the_object = model . objects . filter ( ** kwargs ) if ( len ( the_object ) == 1 ) : the_object = the_object [ 0 ] else : the_object = None return the_object
retrive object from name .