Opened 11 years ago

Closed 10 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: master
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


In the documentation in the section: 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)

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 =

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)

6891.diff (591 bytes) - added by Jeff Anderson 10 years ago.
worked up a patch

Download all attachments as: .zip

Change History (5)

comment:1 Changed 11 years ago by Eric Holscher

Component: django.newformsDocumentation

comment:2 Changed 11 years ago by Eric Holscher

Needs documentation: set

Changed 10 years ago by Jeff Anderson

Attachment: 6891.diff added

worked up a patch

comment:3 Changed 10 years ago by Jeff Anderson

Has patch: set
Needs documentation: unset
Triage Stage: UnreviewedReady for checkin

comment:4 Changed 10 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(In [7728]) Fixed #6891 -- Clarified modelform usage documentation. Thanks to Eric Holscher for the suggestion.

Note: See TracTickets for help on using tickets.
Back to Top