Changes between Version 5 and Version 6 of NewForms
- Timestamp:
- Jan 22, 2007, 7:07:59 PM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
NewForms
v5 v6 3 3 4 4 == Widgets [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L8 Unit tests] == 5 Each Widget class corresponds to an HTML form widget. A Widgetknows how to5 Each `Widget` subclass corresponds to an HTML form widget. A `Widget` knows how to 6 6 render itself, given a field name and some data. Widgets don't perform 7 7 validation. 8 8 9 9 === Widget types === 10 List of widgettypes with their associated unit test for easy lookup.10 List of `Widget` types with their associated unit test for easy lookup. 11 11 12 12 … … 24 24 25 25 == Fields == 26 Each Field class does some sort of validation. Each Field has a clean() method, which either raises django.newforms.!ValidationErroror returns the "clean" data -- usually a Unicode object, but, in some rare cases, a list.26 Each `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 27 28 Each Field's __init__()takes at least these parameters:28 Each `Field`'s `__init__()` takes at least these parameters: 29 29 30 * ''required'' -- Boolean that specifies whether the field is required. True by default.[[br]]30 * ''required'' -- Boolean that specifies whether the field is required. `True` by default. 31 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 32 * ''default'' -- Widget that it'll use if you don't specify this. In most cases, the default widget is !TextInput. … … 34 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 35 36 Other than that, the Field subclasses have class-specific options for __init__(). For example, !CharField has a max_lengthoption.36 Other than that, the Field subclasses have class-specific options for `__init__()`. For example, !CharField has a `max_length` option. 37 37 38 38 === Field types [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L644 Unit tests] === … … 51 51 ===== !DateField [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L858 Unit test] ===== 52 52 Arguments: 53 * ''input_formats'' -- (optional) A list of strftime()input formats. These will override all other input formats53 * ''input_formats'' -- (optional) A list of `strftime()` input formats. These will override all other input formats 54 54 55 55 ===== !TimeField [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L935 Unit test] ===== … … 69 69 70 70 ===== !BooleanField [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L1302 Unit test] ===== 71 Since html forms either return something like 'fieldname=on' in request.POST or request.GET, this value may not be set in form.clean_data.71 Since 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 72 73 73 Arguments: … … 91 91 A 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). 92 92 93 You can pass it data in __init__(), as a dictionary, this data will usually come from request.POST or request.GET. The dictionaries passed to form need not be complete, a partial or empty dictionary is valid too. If you don't pass any values to the Form's __init__(), or if you pass None, the Form won't do any validation. Form.errors will be an empty dictionary *but* Form.is_valid() will return False. 94 93 You can pass it data in `__init__()`, as a dictionary, this data will usually come from `request.POST` or `request.GET`. The dictionaries passed to form need not be complete, a partial or empty dictionary is valid too. If you don't pass any values to the Form's `__init__()`, or if you pass `None`, the Form won't do any validation. `Form.errors` will be an empty dictionary '''but''' `Form.is_valid()` will return `False`.