Found the answer why BookForm wasn't validating. I needed to
"exclude" the author field from BookForm. As soon as I did that,
everything fell into place.
Quick debugging tip for Django n00bs: I established that the missing
author was the problem by executing this line of code:
>> print
Thanks for the tip. I've now run into another issue. My book isn't
validating. Is there a quick way to figure out what field(s) are
causing this error:
The Book could not be created because the data didn't validate.
On Jun 25, 6:10 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> What
What you would do is:
book_form = BookForm(request.POST)
book = book_form.save(commit=False)
book.author = author
book.save()
what save(commit=False) does, is create a model instance with the data
from the form, but doesn't save it to the db, then you can handle it
like a regular model.
On Jun
For the sake of argument, I have two models: Book and Author. Book
has many fields and has a foreign key relationship with Author.
Author has two fields and no additional relationships. To stay DRY, I
have BookForm and AuthorForm classes that I use to generate the HTML
for each class.
When I
4 matches
Mail list logo