Opened 18 years ago
Closed 18 years ago
#3186 closed enhancement (fixed)
[patch] helper method to prefill a form with data from a database object
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Forms | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Attachments (1)
Change History (2)
by , 18 years ago
Attachment: | django_newforms_from_db_helper2.patch added |
---|
comment:1 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
This essentially is accomplished by the new form_for_instance
helper function.
Patch implementing the "seed from db object" helper (with obvious syntax errors fixed this time)