Ticket #19610: 19610.diff

File 19610.diff, 1.4 KB (added by timo, 15 months ago)
1diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt
2index 4aacbf0..d1f877f 100644
3--- a/docs/ref/forms/api.txt
4+++ b/docs/ref/forms/api.txt
5@@ -716,6 +716,8 @@ form data *and* file data::
6 Testing for multipart forms
7 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
9+.. method:: Form.is_multipart
11 If you're writing reusable views or templates, you may not know ahead of time
12 whether your form is a multipart form or not. The ``is_multipart()`` method
13 tells you whether the form requires multipart encoding for submission::
14diff --git a/docs/topics/forms/index.txt b/docs/topics/forms/index.txt
15index 9b5794a..a3c17e1 100644
16--- a/docs/topics/forms/index.txt
17+++ b/docs/topics/forms/index.txt
18@@ -197,6 +197,14 @@ context variable ``form``. Here's a simple example template::
19 The form only outputs its own fields; it is up to you to provide the surrounding
20 ``<form>`` tags and the submit button.
22+If your form includes uploaded files, be sure to include
23+``enctype="multipart/form-data"`` in the ``form`` element. If you wish to write
24+a generic template that will work whether or not the form has files, you can
25+use the :meth:`~django.forms.Form.is_multipart` attribute on the form::
27+    <form action="/contact/" method="post"
28+        {% if form.is_multipart %}enctype="multipart/form-data"{% endif %}>
30 .. admonition:: Forms and Cross Site Request Forgery protection
32    Django ships with an easy-to-use :doc:`protection against Cross Site Request