简体   繁体   English

django中的用户注册过程?

[英]User registration process in django?

I want user to regist my app in two step 我希望用户分两步注册我的应用

  1. basic info (email username password) 基本信息(电子邮件用户名密码)
  2. realinfo (realname, age, gender ) realinfo(真实姓名,年龄,性别)

and this is how I did 这就是我所做的

def developRegistrationFirstStep(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            new_user = User.objects.create_user(form.cleaned_data['username'], form.cleaned_data['email'], form.cleaned_data['password1'])
            # user = authenticate(username=form.cleaned_data['email'], password=form.cleaned_data['password1'])
            # if user is not None:
            #    if user.is_active:
            #       login(request, user)
            return redirect('registration/secondstep')
   else:
       form = RegistrationForm()
   return render_to_response('registration/registration_form.html',{'form':form},context_instance=RequestContext(request))

def developRegistrationSecondStep(request):

    if request.method == 'POST':
        form = ProfileInfo(request.POST)
        if form.is_valid():
            pass

note that both registration step has to be finished before the user can login 请注意,必须先完成两个注册步骤,然后用户才能登录

as u can see after user done with first step,I redirect the user to the second step,and here is the problem, in second step how can I get this half registed user? 如您在用户完成第一步后所看到的,我将用户重定向到第二步,这就是问题所在,在第二步中,我如何才能获得这一半注册的用户? because I stroe the realinfo in UserProfile model,which gets created once the user instance gets created, I need to save the realinfo into this user's UserProfile, how can I do that? 因为我对UserProfile模型中创建的realinfo进行了搜索,一旦创建了用户实例,就将其创建,因此我需要将realinfo保存到该用户的UserProfile中,该怎么做?

这正是Django 表单向导是有用的工具

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM