Opened 8 years ago

Closed 7 years ago

#6891 closed (fixed)

Modelform documentation on editing an existing object needs to be updated.

Reported by: ericholscher 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: UI/UX:


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 programmerq 7 years ago.
worked up a patch

Download all attachments as: .zip

Change History (5)

comment:1 Changed 8 years ago by ericholscher

  • Component changed from django.newforms to Documentation
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 8 years ago by ericholscher

  • Needs documentation set

Changed 7 years ago by programmerq

worked up a patch

comment:3 Changed 7 years ago by programmerq

  • Has patch set
  • Needs documentation unset
  • Triage Stage changed from Unreviewed to Ready for checkin

comment:4 Changed 7 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(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