From 0de2645c00c2330060c9889c71afd3a528ed7a3a Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 23 Jan 2013 04:42:34 -0500 Subject: [PATCH] Fixed #19610 - Added enctype note to forms topics doc. Thanks will@ for the suggestion. --- docs/ref/forms/api.txt | 2 ++ docs/topics/forms/index.txt | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt index 4aacbf0a0d..d1f877ff65 100644 --- a/docs/ref/forms/api.txt +++ b/docs/ref/forms/api.txt @@ -716,6 +716,8 @@ form data *and* file data:: Testing for multipart forms ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.. method:: Form.is_multipart + 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:: diff --git a/docs/topics/forms/index.txt b/docs/topics/forms/index.txt index 9b5794a8f2..a3c17e1555 100644 --- a/docs/topics/forms/index.txt +++ b/docs/topics/forms/index.txt @@ -197,6 +197,14 @@ context variable ``form``. Here's a simple example template:: The form only outputs its own fields; it is up to you to provide the surrounding ``
`` tags and the submit button. +If your form includes uploaded files, be sure to include +``enctype="multipart/form-data"`` in the ``form`` element. If you wish to write +a generic template that will work whether or not the form has files, you can +use the :meth:`~django.forms.Form.is_multipart` attribute on the form:: + + + .. admonition:: Forms and Cross Site Request Forgery protection Django ships with an easy-to-use :doc:`protection against Cross Site Request