[patch] helper method to prefill a form with data from a database object
|Reported by:||Owned by:||Adrian Holovaty|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
A form in the application I'm writing is a very near match to an underlying database object: It's just missing a few "non-public" fields, which get handled by the app itself. My form view needs to be able to handle both entering new data and editing existing data. In the latter case, I need a method that will prefill my form with the existing data before returning it to the user.
I couldn't find such a method in django.newforms, so here is a request for adding such a method :). Attached is a patch which implements this helper in django.newforms.models. It'll probably take some massaging to get into the spirit of the rest of the newforms module, but it works for me so far, and I think it'd be a useful helper.