Well im talking about save a form yes, but in the same moment i want to save x data in another table, for example, i want to generate some "key" while im saving the form data, but i want to save the "key" in another table.
Thanks On Jul 29, 8:52 pm, mike <mkimm...@gmail.com> wrote: > On Jul 29, 3:39 pm, Asinox <asi...@gmail.com> wrote: > > > Hi guys, i cant find a example about how ill save data in two or more > > tables... somebody help me please > > > Thanks > > You essentially use two form instances and feed both to your > template. You can have multiple django forms in a single html form, > so when they're submitted, you simply check that both django forms are > valid before saving. > > Here's a snippet: > > if request.method == 'POST' and request.POST.get('save', '') == > 'Save': > > Form1 = mainForm(request.POST) > Form2 = subForm(request.POST) > > if Form1.is_valid() and Form2.is_valid(): > # do whatever else you need > # > # then save forms > Form1.save() > Form2.save() > > # return success response... > else: > # return forms for corrections... --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---