Example Needed: Pass the submitted form information to review page

I have a form using modelForm I need an example or code of the views.py and related files to create another page where users can view the information they submitted. I can think of doing it with the primary key of the database they saved to but how do i redirect them to another template with the information from the form they just entered.

I also need a permalink to that page so others can type in a url to see that information review page

Thank you very much for your help, you can also redirect me to a url with an example like above if you know of one

Answers


I think it can be done this way...

For example, you have a registration form that takes in modelform

class RegistrationForm(ModelForm):
    username = forms.CharField(label=(u'User Name'))
    email = forms.EmailField(label =(u'Email Address'))
    password = forms.CharField(label =(u'Password'),widget=forms.PasswordInput(render_value=False))
    password1 = forms.CharField(label =(u'Verify Password'),widget=forms.PasswordInput(render_value=False))

    class Meta:
        model = Drinker
        exclude = ('user',)

Then the view:

def Registration(request):
    if request.POST:
        form =RegistrationForm(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['password']
            user.save()
            path = reverse('Review', dict(user=user,email=email,password=password)
            return HttpResponseRedirect(path)
        else:
            return render(request,'register.html',{'form':form,})
    else:
        form = RegistrationForm()
        return render(request,'register.html',{'form':form,})

Then just create another view:

def Review(request):
    render(request,'review.html',dict(user=user,email=email,password=password))

Then display it in the review.html... Hope this helps...


Need Your Help

Dictionary<TKey, TValue> override Indexer and FindEntry

c# dictionary mono

In order to optimize my code, I'm trying to create my own Indexer and my own version of the FindEntry function - so that I can do something like the following within a Dictionary-like class:

MySQL WHERE based on PHP variable

php mysql sql dynamic

I have a form where I collect a bunch of basic information (name, email, etc), I then post that to a database. On that form, I use the php date function to insert a "day", "month", and "year" data...