示例#1
0
def add_User(request):
    form = UserCreateForm()
    if request.method == "POST":
        form = UserCreateForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect("home")
    return render_to_response("add_User.html", {"form": form}, RequestContext(request))
示例#2
0
def add_User(request):
    form = UserCreateForm()
    if request.method == 'POST':
        form = UserCreateForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect('home')
    return render_to_response('add_User.html', {
        'form': form,
    }, RequestContext(request))
示例#3
0
def registro(request):
    form = UserCreateForm
    if request.method == 'POST':
        form = UserCreateForm(request.POST)
        if form.is_valid():
            user = form.save()
            UserProfile.objects.create(user=user)
            return redirect('login')
    return render_to_response('registro.html', {
        'form': form,
    }, RequestContext(request))
示例#4
0
文件: views.py 项目: CS2014/USM
def signup(request):
        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)                   
                    login(request, user)
                    return redirect("/")
            else:
                return render(request,
                                    'main/signup.html',
                                    { 'form' : user_form })
        return render(request,
                            'main/signup.html')     
示例#5
0
def Registration(request):
    if request.user.is_authenticated():
            return HttpResponseRedirect('/profile/')
    if request.method == 'POST':
            form = UserCreateForm(request.POST)
            if form.is_valid():
                    user = User.objects.create_user(username=form.cleaned_data['username'], email=form.cleaned_data['email'], password=form.cleaned_data['password1'])
                    user.save()
                    users = UserProfile(user=user, name=form.cleaned_data['name'], 
                        birthday=form.cleaned_data['birthday'], location=form.cleaned_data['location'], 
                        bio=form.cleaned_data['bio'], private=form.cleaned_data['private'])
                    users.save()
                    return redirect('LoginRequest')
            else:
                    return render_to_response('register.html', {'form': form}, context_instance=RequestContext(request))
    else:
            ''' user is not submitting the form, show them a blank registration form '''
            form = UserCreateForm()
            context = {'form': form}
            return render_to_response('register.html', context, context_instance=RequestContext(request))