Opened 17 years ago
Closed 16 years ago
#6891 closed (fixed)
Modelform documentation on editing an existing object needs to be updated.
Reported by: | Eric Holscher | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In the documentation in the section: the save method:
http://www.djangoproject.com/documentation/modelforms/#the-save-method
It is unclear that when you are creating a modelform of POSTed object, the correct syntax is:
article = Article.objects.get(pk=id) new = ModelForm(request.POST, article) new.save()
for when you are trying to update an object, instead of create a new one.
The code section:
# Create a form instance with POST data. >>> a = Author() >>> f = AuthorForm(request.POST, instance=a) # Create and save the new author instance. There's no need to do anything else. >>> new_author = f.save()
is the second example of creating a form with POST data, and should instead show how to update a form with POST data.
Attachments (1)
Change History (5)
comment:1 by , 17 years ago
Component: | django.newforms → Documentation |
---|
comment:2 by , 17 years ago
Needs documentation: | set |
---|
by , 16 years ago
comment:3 by , 16 years ago
Has patch: | set |
---|---|
Needs documentation: | unset |
Triage Stage: | Unreviewed → Ready for checkin |
comment:4 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
worked up a patch