Thursday, July 26, 2007

django's newforms

I've been anxiously awaiting for a long time for the newforms documentation to show up in the on line beta of the django book. It's still not there so I took matters into my own hands and did the unthinkable: I read the documentation on the django site. I know, I know, what sort of loser reads the documentation?  Desparate times call for desperate measures friends.

Anyway I think the use and function of newforms has finally settled in my brain.  Partly because I copied someones example a few months back and got it working though I didn't thoroughly understand it.  Partly because I read thru the documentation for the 3rd time. And party because I read through the unit test code for newforms.

Any way my issue was that I was trying to clone an existing object. The breakthrough was realizing that I could call form.save(commit=False) so that I could intercept the resulting model instance and set the id = None before saving it so i didn't update the original object in anyway.

I just may get the hang of this django thing one of these days...

No comments: