From fcec755f01cfaba2a85bfc9511876debbce98631 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Fri, 17 Aug 2007 15:05:54 +0000 Subject: newforms-admin: Merged from trunk up to [5916] git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@5918 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/newforms.txt | 179 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 175 insertions(+), 4 deletions(-) (limited to 'docs/newforms.txt') diff --git a/docs/newforms.txt b/docs/newforms.txt index acc28604df..803dc6458a 100644 --- a/docs/newforms.txt +++ b/docs/newforms.txt @@ -678,7 +678,7 @@ The easiest way is to iterate over the form's fields, with
{% for field in form %} -
{{ field.label }}
+
{{ field.label_tag }}
{{ field }}
{% if field.help_text %}
{{ field.help_text }}
{% endif %} {% if field.errors %}
{{ field.errors }}
{% endif %} @@ -698,11 +698,11 @@ For example::
    -
  • {{ form.sender.label }} {{ form.sender }}
  • +
  • {{ form.sender.label_tag }} {{ form.sender }}
  • {{ form.sender.help_text }}
  • {% if form.sender.errors %}
      {{ form.sender.errors }}
    {% endif %} -
  • {{ form.subject.label }} {{ form.subject }}
  • +
  • {{ form.subject.label_tag }} {{ form.subject }}
  • {{ form.subject.help_text }}
  • {% if form.subject.errors %}
      {{ form.subject.errors }}
    {% endif %} @@ -962,7 +962,7 @@ validation if a particular field's value is not given. ``initial`` values are ~~~~~~~~~~ The ``widget`` argument lets you specify a ``Widget`` class to use when -rendering this ``Field``. See "Widgets" below for more information. +rendering this ``Field``. See "Widgets"_ below for more information. ``help_text`` ~~~~~~~~~~~~~ @@ -1129,6 +1129,24 @@ If no ``input_formats`` argument is provided, the default input formats are:: '%m/%d/%y %H:%M', # '10/25/06 14:30' '%m/%d/%y', # '10/25/06' +``DecimalField`` +~~~~~~~~~~~~~~~~ + +**New in Django development version** + + * Default widget: ``TextInput`` + * Empty value: ``None`` + * Normalizes to: A Python ``decimal``. + * Validates that the given value is a decimal. Leading and trailing + whitespace is ignored. + +Takes four optional arguments: ``max_value``, ``min_value``, ``max_digits``, +and ``decimal_places``. The first two define the limits for the fields value. +``max_digits`` is the maximum number of digits (those before the decimal +point plus those after the decimal point, with leading zeros stripped) +permitted in the value, whilst ``decimal_places`` is the maximum number of +decimal places permitted. + ``EmailField`` ~~~~~~~~~~~~~~ @@ -1199,6 +1217,9 @@ When you use a ``FileField`` on a form, you must also remember to * Validates that the given value is an integer. Leading and trailing whitespace is allowed, as in Python's ``int()`` function. +Takes two optional arguments for validation, ``max_value`` and ``min_value``. +These control the range of values permitted in the field. + ``MultipleChoiceField`` ~~~~~~~~~~~~~~~~~~~~~~~ @@ -1416,6 +1437,156 @@ like so:: senders = MultiEmailField() cc_myself = forms.BooleanField() +Widgets +======= + +A widget is Django's representation of a HTML input element. The widget +handles the rendering of the HTML, and the extraction of data from a GET/POST +dictionary that corresponds to the widget. + +Django provides a representation of all the basic HTML widgets, plus some +commonly used groups of widgets: + + ============================ =========================================== + Widget HTML Equivalent + ============================ =========================================== + ``TextInput`` ``...`` + ``CheckboxInput`` ``