本文整理汇总了Python中django.contrib.auth.forms.AuthenticationForm.full_clean方法的典型用法代码示例。如果您正苦于以下问题:Python AuthenticationForm.full_clean方法的具体用法?Python AuthenticationForm.full_clean怎么用?Python AuthenticationForm.full_clean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.auth.forms.AuthenticationForm
的用法示例。
在下文中一共展示了AuthenticationForm.full_clean方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: app_login
# 需要导入模块: from django.contrib.auth.forms import AuthenticationForm [as 别名]
# 或者: from django.contrib.auth.forms.AuthenticationForm import full_clean [as 别名]
def app_login(request):
"""
Attempts to authenticate a user to Aristotle Library Apps
:param request: HTTP Request
"""
if request.method == 'GET':
return HttpResponse("IN GET App Login")
username = request.POST['username']
password = request.POST['password']
next_page = request.REQUEST.get('next')
errors = []
try:
user = authenticate(last_name=username,
iii_id=password)
except KeyError:
user = None
if user is not None:
if user.is_active:
login(request, user)
if len(next_page) > 0:
return redirect(next_page)
else:
return redirect('/apps')
else:
error_msg = "User not active"
logger.error(error_msg)
errors.append(error_msg)
else:
error_msg = "User {0} not found or unable to authenticate".format(username)
logger.error(error_msg)
errors.append(error_msg)
auth_form = AuthenticationForm(request.POST)
auth_form.full_clean()
auth_form._errors[NON_FIELD_ERRORS] = auth_form.error_class(errors)
return direct_to_template(request,
'registration/login.html',
{'app':None,
'institution':json_loader.get('institution'),
'form': auth_form,
'navbar_menus':json_loader.get('navbar-menus'),
'user':user})