def register(request):
username = auth.get_user(request).username
if not (username):
args={}
args.update(csrf(request))
args['form']=UserCreationForm()
if request.POST:
newuser_form=UserCreationForm(request.POST)
if newuser_form.is_valid():
newuser_form.save()
newuser = auth.authenticate(username=newuser_form.cleaned_data['username'],password=newuser_form.cleaned_data['password2'])
auth.login(request, newuser)
return redirect('/')
else:
args['errors'] = format_html('<div class="main-error alert alert-error">?????? ??? ???????????</div>')
args['form'] = newuser_form
return render_to_response('register.html',args)
else:
return redirect('/')
评论列表
文章目录