I have just started learning django. I created a form from django models. On the click of submit button the data is getting stored in database. Now what i want is something like the one given below :
#view.py
def contact(request):
if request.method == 'POST':
form = UserForm(request.POST)
if form.is_valid():
user = form.save()
return HttpResponseRedirect("/contact/create_db")
#urls.py
(r'^contact/$', views.contact),
(r'^contact/create_db$', views.do_create),
Now when i define do_create function in views.py i want to pass the arguments(user data of user form) like this:
def do_create(request, password, dbname, admin_password, confirm_password, demo_data=False, language=None, **kw):
Is this possible using django. How can this be achieved.
All you’re asking here is how to get the value of the saved
userin a subsequent view.Well, this is easy. Once the user is saved, it (like any model instance) gets a
pkvalue. You can use this in the URL for the subsequent view.In
contact:And in
do_create:Note the way I’ve passed in the URL name and arguments into
redirect, rather than hard-coding the URL.