def get_user_from_identifier(identifier):
 identifier = identifier.strip()
 if ('@' in identifier):
  user = User.objects.get(email=identifier)
 else:
  user = User.objects.get(username=identifier)
 return user

def get_user_from_identifier ( identifier ) : identifier = identifier . strip ( ) if ( '@' in identifier ) : user = User . objects . get ( email = identifier ) else : user = User . objects . get ( username = identifier ) return user
this function takes the string identifier and fetch relevant user object from database .