On Jul 29, 3:39 pm, Asinox <[email protected]> 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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---