Re: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread ayayalar
Thank you for the advise. I just started using Django and sometimes it takes time to get used to do certain things. Regards, Arif On Nov 20, 3:40 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-11-20 at 15:18 -0800, ayayalar wrote: > > I understand, I wish it was possible to b

Re: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread Malcolm Tredinnick
On Thu, 2008-11-20 at 15:18 -0800, ayayalar wrote: > I understand, I wish it was possible to bind multiple view functions > to a single template through the urls... Why? It's the wrong level of coupling. Each URL patterns ends up resolving to a single view function. However that view function ca

Re: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread ayayalar
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

Re: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread ayayalar
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})

Re: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread Brian Neal
On Nov 20, 4:50 pm, ayayalar <[EMAIL PROTECTED]> wrote: > And I do that. Here is my template: > No, you are not. Check the dictionary you are passing into your render_to_response() calls again. --~--~-~--~~~---~--~~ You received this message because you are subscrib

Re: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread ayayalar
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

Re: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread Malcolm Tredinnick
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

Re: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread Karen Tracey
On Thu, Nov 20, 2008 at 5:03 PM, ayayalar <[EMAIL PROTECTED]> wrote: > > VIEW: > > def add_product(request): >if not request.method == 'POST': >form1 = ProductForm() >return render_to_response('index.html', {'form1' : form1}) >else: >form1 = ProductForm(request.POST

Re: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread Andy McKay
Yes but you never pass two forms to the template at the same time. In add_product you pass form1, in add_product_details you pass form2. >>> (r'^product/$', views.add_product), >>> (r'^product/$', views.add_product_details), You have the same URL twice, only one of them will ever be ac

Re: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread ayayalar
And I do that. Here is my template: {{ form1.as_table }} {{ form2.as_table }} On Nov 20, 2:15 pm, Brian Neal <[EMAIL PROTECTED]> wrote: > On Nov 20, 4:03 pm, ayayalar <[EMAIL PROTECTED]> wrote

Re: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread Brian Neal
On Nov 20, 4:03 pm, ayayalar <[EMAIL PROTECTED]> wrote: > VIEW: > > def add_product(request): >     if not request.method == 'POST': >         form1 = ProductForm() >         return render_to_response('index.html', {'form1' : form1}) >     else: >         form1 = ProductForm(request.POST) >      

Is it possible to display multiple forms in a single template file?

2008-11-20 Thread ayayalar
VIEW: def add_product(request): if not request.method == 'POST': form1 = ProductForm() return render_to_response('index.html', {'form1' : form1}) else: form1 = ProductForm(request.POST) if form1.is_valid(): form1.save() return HttpRe