Code

Changes between Version 5 and Version 6 of NewForms


Ignore:
Timestamp:
01/22/07 17:07:59 (7 years ago)
Author:
Gary Wilson <gary.wilson@…>
Comment:

some wikification

Legend:

Unmodified
Added
Removed
Modified
  • NewForms

    v5 v6  
    33 
    44== 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 Widget knows how to 
     5Each `Widget` subclass corresponds to an HTML form widget. A `Widget` knows how to 
    66render itself, given a field name and some data. Widgets don't perform 
    77validation. 
    88 
    99=== Widget types === 
    10 List of widget types with their associated unit test for easy lookup. 
     10List of `Widget` types with their associated unit test for easy lookup. 
    1111 
    1212 
     
    2424 
    2525== Fields == 
    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. 
     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. 
    2727 
    28 Each Field's __init__() takes at least these parameters: 
     28Each `Field`'s `__init__()` takes at least these parameters: 
    2929 
    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. 
    3131 * ''widget'' -- A Widget class, or instance of a Widget class, that should be used for this Field when displaying it. Each Field has a  
    3232 * ''default'' -- Widget that it'll use if you don't specify this. In most cases, the default widget is !TextInput. 
     
    3434 * ''initial'' -- A value to use in this Field's initial display. This value is *not* used as a fallback if data isn't given. 
    3535 
    36 Other than that, the Field subclasses have class-specific options for __init__(). For example, !CharField has a max_length option. 
     36Other than that, the Field subclasses have class-specific options for `__init__()`. For example, !CharField has a `max_length` option. 
    3737 
    3838=== Field types [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L644 Unit tests] === 
     
    5151===== !DateField [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L858 Unit test] ===== 
    5252Arguments: 
    53  * ''input_formats'' -- (optional) A list of strftime() input formats. These will override all other input formats 
     53 * ''input_formats'' -- (optional) A list of `strftime()` input formats. These will override all other input formats 
    5454 
    5555===== !TimeField  [http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py#L935 Unit test] ===== 
     
    6969 
    7070===== !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.  
     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()`. 
    7272 
    7373Arguments: 
     
    9191A 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).  
    9292 
    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  
     93You 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`.