Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.5.x] Fixed #19610 - Added enctype note to forms topics doc.

Thanks will@ for the suggestion.

Backport of 0de2645 from master
  • Loading branch information...
commit 2e6b0c5ca7265b3cee2ff68a9ef5d1865afb9a49 1 parent f413214
Tim Graham authored January 23, 2013
2  docs/ref/forms/api.txt
@@ -716,6 +716,8 @@ form data *and* file data::
716 716
 Testing for multipart forms
717 717
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
718 718
 
  719
+.. method:: Form.is_multipart
  720
+
719 721
 If you're writing reusable views or templates, you may not know ahead of time
720 722
 whether your form is a multipart form or not. The ``is_multipart()`` method
721 723
 tells you whether the form requires multipart encoding for submission::
8  docs/topics/forms/index.txt
@@ -197,6 +197,14 @@ context variable ``form``. Here's a simple example template::
197 197
 The form only outputs its own fields; it is up to you to provide the surrounding
198 198
 ``<form>`` tags and the submit button.
199 199
 
  200
+If your form includes uploaded files, be sure to include
  201
+``enctype="multipart/form-data"`` in the ``form`` element. If you wish to write
  202
+a generic template that will work whether or not the form has files, you can
  203
+use the :meth:`~django.forms.Form.is_multipart` attribute on the form::
  204
+
  205
+    <form action="/contact/" method="post"
  206
+        {% if form.is_multipart %}enctype="multipart/form-data"{% endif %}>
  207
+
200 208
 .. admonition:: Forms and Cross Site Request Forgery protection
201 209
 
202 210
    Django ships with an easy-to-use :doc:`protection against Cross Site Request

0 notes on commit 2e6b0c5

Please sign in to comment.
Something went wrong with that request. Please try again.