Skip to content

Commit

Permalink
Fixed #6891 -- Clarified modelform usage documentation. Thanks to Eri…
Browse files Browse the repository at this point in the history
…c Holscher for the suggestion.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7728 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
freakboy3742 committed Jun 23, 2008
1 parent 3ce8106 commit dce557b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/modelforms.txt
Expand Up @@ -182,6 +182,13 @@ supplied, ``save()`` will update that instance. If it's not supplied,
# Create a form to edit an existing Article.
>>> a = Article.objects.get(pk=1)
>>> f = ArticleForm(instance=a)
>>> f.save()

# Create a form to edit an existing Article, but use
# POST data to populate the form.
>>> a = Article.objects.get(pk=1)
>>> f = ArticleForm(request.POST, instance=a)
>>> f.save()

Note that ``save()`` will raise a ``ValueError`` if the data in the form
doesn't validate -- i.e., ``if form.errors``.
Expand Down

0 comments on commit dce557b

Please sign in to comment.