ayayalar wrote: > I have the following forms: > > from django.forms.models import ModelForm > from demo.home.models import Product, ProductDetail > > class ProductForm(ModelForm): > class Meta: > model = Product > > > class ProductDetailForm(ModelForm): > class Meta: > model = ProductDetail > > > I am trying to handle the submission of these forms in a single > method. > > def add_product(request): > if not request.method == 'POST': > form1 = ProductForm(); > form2 = ProductDetailForm() > return render_to_response('index.html', {'form1' : form1, > 'form2' : form2}) > else: > #Need to process the forms here. > > > > How do I know which form is submitted? > Well, that really depends on the HTML you have put around the forms. One possible way would be to have two different submit buttons with the same name and different values, then use the value to distinguish between them.
This presumes you only want to action the form whose submit button is clicked? A further, and even easier, way is to give each form a different action attribute. Then they will trigger different views! regards Steve --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---