summaryrefslogtreecommitdiff
path: root/docs/newforms.txt
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2007-09-15 21:57:25 +0000
committerAdrian Holovaty <adrian@holovaty.com>2007-09-15 21:57:25 +0000
commitca33d307dee3cf68cc9cd2ccfae00c7ff23ea890 (patch)
treee0f0afa392f4ab50de4a89e2a0b1b4cc53f40794 /docs/newforms.txt
parent7325fbf4ff20f9b0f21d3a1aba1abaca78a765d7 (diff)
queryset-refactor: Merged to [6300]
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6340 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/newforms.txt')
-rw-r--r--docs/newforms.txt21
1 files changed, 21 insertions, 0 deletions
diff --git a/docs/newforms.txt b/docs/newforms.txt
index e9e98944a0..19c5fc247f 100644
--- a/docs/newforms.txt
+++ b/docs/newforms.txt
@@ -776,6 +776,27 @@ form data *and* file data::
# Unbound form with a image field
>>> f = ContactFormWithMugshot()
+Testing for multipart forms
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If you're writing reusable views or templates, you may not know ahead of time
+whether your form is a multipart form or not. The ``is_multipart()`` method
+tells you whether the form requires multipart encoding for submission::
+
+ >>> f = ContactFormWithMugshot()
+ >>> f.is_multipart()
+ True
+
+Here's an example of how you might use this in a template::
+
+ {% if form.is_multipart %}
+ <form enctype="multipart/form-data" method="post" action="/foo/">
+ {% else %}
+ <form method="post" action="/foo/">
+ {% endif %}
+ {% form %}
+ </form>
+
Subclassing forms
-----------------