From cd20b5d1864e3c0f2d9ce8b9d186c201e5d89c00 Mon Sep 17 00:00:00 2001 From: Daniele Procida Date: Sun, 8 Jun 2014 19:30:52 +0100 Subject: [PATCH] Fixed #22796 -- Added a more basic explanations of forms. Thanks bmispelon, kezabelle, jorgecarleitao, and timgraham for reviews. --- docs/ref/forms/api.txt | 4 + docs/spelling_wordlist | 2 + docs/topics/forms/formsets.txt | 2 +- docs/topics/forms/index.txt | 712 +++++++++++++++++++++++---------- 4 files changed, 505 insertions(+), 215 deletions(-) diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt index 10e85b4019..8909d5c916 100644 --- a/docs/ref/forms/api.txt +++ b/docs/ref/forms/api.txt @@ -376,6 +376,8 @@ You can write code to perform validation for particular form fields (based on their name) or for the form as a whole (considering combinations of various fields). More information about this is in :doc:`/ref/forms/validation`. +.. _ref-forms-api-outputting-html: + Outputting forms as HTML ------------------------ @@ -492,6 +494,8 @@ it calls its ``as_table()`` method behind the scenes:: +.. _ref-forms-api-styling-form-rows: + Styling required or erroneous form rows ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/spelling_wordlist b/docs/spelling_wordlist index 8b8f3c17f0..806fa333cd 100644 --- a/docs/spelling_wordlist +++ b/docs/spelling_wordlist @@ -1,3 +1,4 @@ +à Aalto accessor Aceh @@ -153,6 +154,7 @@ dirmod distro divisibleby django +Django's djangojs djangonaut djangoproject diff --git a/docs/topics/forms/formsets.txt b/docs/topics/forms/formsets.txt index e4aa7b5984..7595bbe4ae 100644 --- a/docs/topics/forms/formsets.txt +++ b/docs/topics/forms/formsets.txt @@ -56,7 +56,7 @@ Using initial data with a formset Initial data is what drives the main usability of a formset. As shown above you can define the number of extra forms. What this means is that you are telling the formset how many additional forms to show in addition to the -number of forms it generates from the initial data. Lets take a look at an +number of forms it generates from the initial data. Let's take a look at an example:: >>> import datetime diff --git a/docs/topics/forms/index.txt b/docs/topics/forms/index.txt index 8db24f68d0..a8730871e5 100644 --- a/docs/topics/forms/index.txt +++ b/docs/topics/forms/index.txt @@ -2,128 +2,372 @@ Working with forms ================== +.. currentmodule:: django.forms + .. admonition:: About this document - This document provides an introduction to Django's form handling features. - For a more detailed look at specific areas of the forms API, see - :doc:`/ref/forms/api`, :doc:`/ref/forms/fields`, and + This document provides an introduction to the basics of web forms and how + they are handled in Django. For a more detailed look at specific areas of + the forms API, see :doc:`/ref/forms/api`, :doc:`/ref/forms/fields`, and :doc:`/ref/forms/validation`. -.. highlightlang:: html+django +Unless you're planning to build websites and applications that do nothing but +publish content, and don't accept input from your visitors, you're going to +need to understand and use forms. -``django.forms`` is Django's form-handling library. +Django provides a range of tools and libraries to help you build forms to +accept input from site visitors, and process and respond to the input. -While it is possible to process form submissions just using Django's -:class:`~django.http.HttpRequest` class, using the form library takes care of a -number of common form-related tasks. Using it, you can: +HTML forms +========== -1. Display an HTML form with automatically generated form widgets. -2. Check submitted data against a set of validation rules. -3. Redisplay a form in the case of validation errors. -4. Convert submitted form data to the relevant Python data types. +In HTML, a form is a collection of elements inside ``
...
`` that +allow a visitor to do things like enter text, select options, manipulate +objects or controls, and so on, and then send that information back to the +server. -Overview -======== +Some of these form interface elements - text input or checkboxes - are fairly +simple and built-in to HTML itself. Others are much more complex; an interface +that pops up a date picker or allows you to move a slider or manipulate +controls will typically use JavaScript and CSS as well as HTML form ```` +elements to achieve these effects. -The library deals with these concepts: +As well as its ```` elements, a form must specify two things: -.. glossary:: +* *where*: the URL to which the data corresponding to the user's input should + be returned - Widget - A class that corresponds to an HTML form widget, e.g. - ```` or ``