Ejemplo n.º 1
0
def user_profile(request):
    if request.method == 'POST':
        form = UserDetailForm(request.POST, instance=request.user.profile)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/accounts/loggedin')
    else:
        userid = request.GET.get('userid', '')
        user = UserDetail.objects.filter(user_id=userid)

    args = {}
    args.update(csrf(request))

    args['user'] = user

    return render(request, 'profile.html', args)
Ejemplo n.º 2
0
def register_user(request):
    if request.method == 'POST':
        form = MyRegistrationForm(request.POST)
        uform = UserDetailForm(request.POST)
        print "here"
        if form.is_valid():
            print "Form1 is valid"
            if uform.is_valid():
                print "Form2 is valid"
                user = form.save()
                userprofile = uform.save(commit=False)
                userprofile.user = user
                userprofile.save()
                return HttpResponseRedirect('/accounts/register_success')
    args = {}
    args.update(csrf(request))

    args['form'] = MyRegistrationForm()
    args['uform'] = UserDetailForm()

    return render(request, 'register.html', args)