views.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:trunk-player 作者: ScanOC 项目源码 文件源码
def register(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            user = User.objects.create_user(
            username=form.cleaned_data['username'],
            password=form.cleaned_data['password1'],
            email=form.cleaned_data['email']
            )
            username = form.cleaned_data['username']
            password = form.cleaned_data['password1']
            new_user = authenticate(username=username, password=password)
            if new_user is not None:
                if new_user.is_active:
                    stripe_actions.customers.create(user=new_user)
                    login(request, new_user)
                    return HttpResponseRedirect('/scan/default/')
                else:
                    # this would be weird to get here
                    return HttpResponseRedirect('/register/success/')
            else:
                return HttpResponseRedirect('/register/success/')
    else:
        form = RegistrationForm()

    return render(
    request,
    'registration/register.html',
    { 'form': form },
    )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号