Beispiel #1
0
def register(req):
    #注册认证  
    if req.method=='POST':
       
        rf = RegisterForm(req.GET)
        user = User()
        user.email = rf.cleaned_data['user_email']
        user.name = rf.cleaned_data['user_name']
        user.pw = rf.cleaned_data['user_password']
        user.birthday = rf.cleaned_data['user_birthday']
        user.school = rf.cleaned_data['user_school']
        user.is_boy = rf.cleaned_data['user_gender']
        user.save()
        return HttpResponse('hello')
        
    else:
        #t = get_template('register.html')
        rf = RegisterForm()
        return render_to_response('register.html', rf, context_instance=RequestContext(req))
Beispiel #2
0
def register(req):
    #注册认证  
    if req.method=='POST':
        new_user = User()
        new_user.email = req.POST['email']
        new_user.name = req.POST['name']
        new_user.pw = req.POST['pass']
        new_user.birthday = req.POST['birthday']
        new_user.is_boy = bool(req.POST['gender'])
        new_user.school = req.POST['school']
        
        if (len(User.objects.filter(email=new_user.email)) <= 0):
            new_user.save()
            return HttpResponseRedirect('/quanzi/login/')
        else:
            t = get_template('register1.html')
            html = t.render(Context({}))
            return HttpResponse(html)
            
    else:
        #t = get_template('register.html')
        t = get_template('register1.html')
        html = t.render(Context({}))
        return HttpResponse(html)