Changes between Initial Version and Version 1 of NewForms


Ignore:
Timestamp:
Jan 3, 2007, 3:10:45 PM (18 years ago)
Author:
anonymous
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • NewForms

    v1 v1  
     1= !NewForms =
     2Since newforms is mostly undocumented at the moment this page summarizes some useful information. This documentation should be considered complementary to the documentation on [http://www.djangoproject.com/documentation/newforms/]. It's mostly information extracted from the [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py unit tests for newforms] at the moment.
     3
     4== Widgets [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L8 Unit tests] ==
     5Each Widget class corresponds to an HTML form widget. A Widget knows how to
     6render itself, given a field name and some data. Widgets don't perform
     7validation.
     8
     9=== Widget types ===
     10List of widget types with their associated unit test for easy lookup.
     11
     12
     13===== !TextInput [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L15 Unit test] =====
     14===== !PasswordInput [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L46 Unit test] =====
     15===== !HiddenInput [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L75 Unit test] =====
     16===== !FileInput [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L109 Unit test] =====
     17===== !TextArea [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L133 Unit test] =====
     18===== !CheckBoxInput [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L162 Unit test] =====
     19===== Select [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L215 Unit test] =====
     20===== !SelectMultiple [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L299 Unit test] =====
     21===== !RadioSelect [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L406 Unit test] =====
     22===== !CheckBoxSelectMultiple [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L536 Unit test] =====
     23
     24
     25== Fields ==
     26Each Field class does some sort of validation. Each Field has a clean() method, which either raises django.newforms.!ValidationError or returns the "clean" data -- usually a Unicode object, but, in some rare cases, a list.
     27
     28Each Field's __init__() takes at least these parameters:
     29
     30 * ''required'' -- Boolean that specifies whether the field is required. True by default.[[br]]
     31 * ''widget'' -- A Widget class, or instance of a Widget class, that should be used for this Field when displaying it. Each Field has a
     32 * ''default'' -- Widget that it'll use if you don't specify this. In most cases, the default widget is !TextInput.
     33 * ''label'' -- A verbose name for this field, for use in displaying this field in a form. By default, Django will use a "pretty" version of  the form field name, if the Field is part of a Form.
     34 * ''initial'' -- A value to use in this Field's initial display. This value is *not* used as a fallback if data isn't given.
     35
     36Other than that, the Field subclasses have class-specific options for __init__(). For example, !CharField has a max_length option.
     37
     38=== Field types [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L644 Unit tests] ===
     39List of field types with their associated unit test for easy lookup.
     40
     41===== !CharField [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L669 Unit test] =====
     42Arguments:
     43 * ''max_length'' -- (optional) Maximum number of characters
     44 * ''min_length'' -- (optional) Minimum number of characters
     45
     46===== !IntegerField [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L735 Unit test] =====
     47Arguments:
     48 * ''max_value'' -- (optional) Maximum value
     49 * ''min_value'' -- (optional) Minimum value
     50
     51===== !DateField [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L858 Unit test] =====
     52Arguments:
     53 * ''input_formats'' -- (optional) A list of strftime() input formats. These will override all other input formats
     54
     55===== !TimeField  [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L935 Unit test] =====
     56
     57===== !DateTimeField  [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L974 Unit test] =====
     58
     59===== !RegexField [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L1047 Unit test] =====
     60Arguments:
     61 * ''regex'' -- The regular expression in compiled or string form that the input should match
     62
     63===== !EmailField [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L1138 Unit test] =====
     64Arguments:
     65 * ''min_length'' -- Minimum length
     66 * ''max_length'' -- Maximum length
     67
     68===== URLField [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L1197 Unit test] =====
     69
     70===== !BooleanField [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L1302 Unit test] =====
     71Since html forms either return something like 'fieldname=on' in request.POST or request.GET, this value may not be set in form.clean_data.
     72
     73Arguments:
     74 * ''None''
     75
     76===== !ChoiceField [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L1340 Unit test] =====
     77Arguments:
     78 * ''choices'' -- A list of (key, value) pairs
     79
     80===== !MultipleChoiceField [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L1382 Unit test] =====
     81Arguments:
     82 * ''choices'' -- A list of (key, value) pairs
     83
     84===== !ComboField [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L1448 Unit test] =====
     85!ComboField takes a list of fields that should be used to validate a value, in that order.
     86
     87Arguments:
     88 * ''choices'' -- A list of fields used to validate the input value
     89clean() returns:
     90 * ''unicode object''
     91
     92== Forms [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L1489 Unit test] ==
     93A Form is a collection of Fields. It knows how to validate a set of data and it knows how to render itself in a couple of default ways (e.g., an HTML table). You can pass it data in __init__(), as a dictionary.
     94
     95
Back to Top