def is_user_lockable(request):
 try:
  field = getattr(User, 'USERNAME_FIELD', 'username')
  kwargs = {field: request.POST.get(USERNAME_FORM_FIELD)}
  user = User.objects.get(**kwargs)
 except User.DoesNotExist:
  return True
 if hasattr(user, 'nolockout'):
  return (not user.nolockout)
 elif hasattr(settings, 'AUTH_PROFILE_MODULE'):
  try:
   profile = user.get_profile()
   if hasattr(profile, 'nolockout'):
    return (not profile.nolockout)
  except (SiteProfileNotAvailable, ObjectDoesNotExist, AttributeError):
   return True
 return True

def is_user_lockable ( request ) : try : field = getattr ( User , 'USERNAME_FIELD' , 'username' ) kwargs = { field : request . POST . get ( USERNAME_FORM_FIELD ) } user = User . objects . get ( ** kwargs ) except User . DoesNotExist : return True if hasattr ( user , 'nolockout' ) : return ( not user . nolockout ) elif hasattr ( settings , 'AUTH_PROFILE_MODULE' ) : try : profile = user . get_profile ( ) if hasattr ( profile , 'nolockout' ) : return ( not profile . nolockout ) except ( SiteProfileNotAvailable , ObjectDoesNotExist , AttributeError ) : return True return True
check if the user has a profile with nolockout if so .