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


Python UserCreateForm.clean_username方法代码示例

本文整理汇总了Python中forms.UserCreateForm.clean_username方法的典型用法代码示例。如果您正苦于以下问题:Python UserCreateForm.clean_username方法的具体用法?Python UserCreateForm.clean_username怎么用?Python UserCreateForm.clean_username使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在forms.UserCreateForm的用法示例。


在下文中一共展示了UserCreateForm.clean_username方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register_user

# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import clean_username [as 别名]
def register_user(request):
    
    template_name = 'kitchen/crispy.html'

    if request.method == 'POST':
        user_form = UserCreateForm(request.POST)
        if user_form.is_valid():
            username = user_form.clean_username()
            password = user_form.clean_password2()
            user_form.save()
            
            user = authenticate(username=username,
                                password=password)
            if user:
                # save extra parameters - email
                user.email = user_form.data['email']
                user.save()
                #ASK - may be we should init it only in one place - on login?
                initUser(user)
                login(request, user)
                return redirect('account-list')
        return render(request,
                      template_name,
                      { 'form' : user_form })
    args = {}
    args.update(csrf(request))
    args['form'] = UserCreateForm()
    print args
    return render(request, template_name, args)
开发者ID:CrowdCafe,项目名称:CrowdKitchen,代码行数:31,代码来源:views.py

示例2: signup

# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import clean_username [as 别名]
def signup(request):
    user_form = UserCreateForm(data=request.POST)
    if request.method == 'POST':
        if user_form.is_valid():
            username = user_form.clean_username()
            password = user_form.clean_password2()
            user_form.save()
            user = authenticate(username=username, password=password)
            login(request, user)
            return redirect('/')
        else:
            return index(request, user_form=user_form)
    return redirect('/')
开发者ID:krist-jin,项目名称:DB_project,代码行数:15,代码来源:views.py

示例3: register

# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import clean_username [as 别名]
def register(request):
	if request.method == 'GET':
		form = UserCreateForm()
		return render_to_response("register.html", RequestContext(request, {"form": form, }))
	else:
		form = UserCreateForm(request.POST)
		if form.is_valid():
			username = form.clean_username()
			password = form.clean_password2()
			
			form.save()
			user = authenticate(username=username, password=password)
			login(request, user)
			return HttpResponseRedirect("/")
		else:
			return render_to_response("register.html", RequestContext(request, {"form": form, "account_error": True }))
开发者ID:wongxinjie,项目名称:readeasy,代码行数:18,代码来源:views.py


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