As you can see I am trying to display a form that points to related models/tables. Any suggestion where I can find a good documentation or an article to accomplish this in "Django" way? I feel like I am not taking the right path
On Nov 20, 3:23 pm, ayayalar <[EMAIL PROTECTED]> wrote: > I am able to do this, but this is pure ugly. Not a very elegant way of > doing things. > > def product(request): > if not request.method == 'POST': > form1 = ProductForm() > form2 = ProductDetailForm() > return render_to_response('index.html', {'form1' : form1, > 'form2' : form2}) > else: > form1 = ProductForm(request.POST) > form2 = ProductDetailForm(request.POST) > if form1.is_valid(): > form1.save() > if form2.is_valid(): > form2.save() > return HttpResponseRedirect('/thanks.html') > > On Nov 20, 3:18 pm, ayayalar <[EMAIL PROTECTED]> wrote: > > > I understand, I wish it was possible to bind multiple view functions > > to a single template through the urls... > > > Would something like this possible? > > > URLS > > urlpatterns = patterns('', > > > (r'^product/$', views.add_product, views.add_product_details),) > > > On Nov 20, 3:07 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> > > wrote: > > > > On Thu, 2008-11-20 at 14:03 -0800, ayayalar wrote: > > > > [...] > > > > > URLS > > > > urlpatterns = patterns('', > > > > > (r'^product/$', views.add_product), > > > > (r'^product/$', views.add_product_details), > > > > This has no chance of doing what you expect. Only one view function will > > > be called for a single request. If you want to pass two form objects to > > > the template, you need to do it from the same view function. You can > > > still put the form creation pieces in separate functions, but your view > > > function will have to call both of them and combine the results into a > > > context to pass to a template. > > > > Regards, > > > Malcolm > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---