当前位置: 首页>>代码示例>>Python>>正文


Python AuthenticationForm.full_clean方法代码示例

本文整理汇总了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})
开发者ID:jermnelson,项目名称:aristotle-library-apps,代码行数:44,代码来源:views.py


注:本文中的django.contrib.auth.forms.AuthenticationForm.full_clean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。