[Answer]-Django submit multipy forms

1๐Ÿ‘

โœ…

You need to check if both forms are valid before performing any action on the data AND only redirect if both forms are valid. This:

    if new_customer.is_valid():
        a = new_customer.save()

        if new_inovce.is_valid():
            ...
    return HttpResponseRedirect('/novi_izlazni_racuni/')

Should be this:

    valid = new_customer.is_valid()
    valid = new_inovce.is_valid() and valid
    if valid:
        a = new_customer.save()
        ...
        return HttpResponseRedirect('/novi_izlazni_racuni/')

This forces both forms to be validated

0๐Ÿ‘

๐Ÿ‘คshalakhin

Leave a comment