Ok this is driving me nuts.  I have two form objects that manipulate
two models.  I am trying to run the is_valid() method on both and then
save the form data to the DB.

def all_valid(form1, form2):
    return form1.is_valid() and form2.is_valid()

def addorder(request):
    today = date.today()
    if request.method == 'POST':
        orderform = OrderForm(request.POST, instance=Order(),
prefix="order")
        equipform = EquipmentForm(request.POST, instance=Equipment(),
prefix="equipment")
        if all_valid(equipform, orderform) == True:
            orderform.save()
            equipform.save()
            return HttpResponseRedirect('/inventory/')
    else:
        orderform = OrderForm(initial={'orderdate': today.strftime('%Y-
%m-%d')}, instance=Order(), prefix="order")
        equipform = EquipmentForm(instance=Equipment(),
prefix="equipment")

    return render_to_response('order_form.html', { 'orderform':
orderform, 'equipform': equipform  })

If I only run is_valid on one form it adds the record correctly.  But
when I add the second form validation check it fails.

Am I missing something?  The data I am inputting into the form is the
correct format (i.e. IntegerField = a number, CharField = characters)

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to