Django

Code

Changeset 5244

Show
Ignore:
Timestamp:
05/14/07 22:37:41 (2 years ago)
Author:
jkocherhans
Message:

newforms-admin: Merged to [5243]. There are 3 failing tests in regressiontests.serializers_regress.tests.SerializerTests?, but they fail in trunk also.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/newforms-admin

    • Property svnmerge-integrated changed from /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-5194 to /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-5243
  • django/branches/newforms-admin/AUTHORS

    r5195 r5244  
    7979    Jure Cuhalev <gandalf@owca.info> 
    8080    dackze+django@gmail.com 
     81    David Danier <goliath.mailinglist@gmx.de> 
    8182    Dirk Datzert <dummy@habmalnefrage.de> 
    8283    Jonathan Daugherty (cygnus) <http://www.cprogrammer.org/> 
     
    8687    deric@monowerks.com 
    8788    Max Derkachev <mderk@yandex.ru> 
     89    Jordan Dimov <s3x3y1@gmail.com> 
    8890    dne@mayonnaise.net 
    8991    Maximillian Dornseif <md@hudora.de> 
  • django/branches/newforms-admin/django/conf/global_settings.py

    r5195 r5244  
    3939    ('ar', gettext_noop('Arabic')), 
    4040    ('bn', gettext_noop('Bengali')), 
     41    ('bg', gettext_noop('Bulgarian')), 
    4142    ('ca', gettext_noop('Catalan')), 
    4243    ('cs', gettext_noop('Czech')), 
  • django/branches/newforms-admin/django/contrib/formtools/preview.py

    r4265 r5244  
    2525Subclass FormPreview and define a done() method: 
    2626 
    27     def done(self, request, clean_data): 
     27    def done(self, request, cleaned_data): 
    2828        # ... 
    2929 
     
    114114            if self.security_hash(request, f) != request.POST.get(self.unused_name('hash')): 
    115115                return self.failed_hash(request) # Security hash failed. 
    116             return self.done(request, f.clean_data) 
     116            return self.done(request, f.cleaned_data) 
    117117        else: 
    118118            return render_to_response(self.form_template, 
     
    161161    # METHODS SUBCLASSES MUST OVERRIDE ######################################## 
    162162 
    163     def done(self, request, clean_data): 
    164         "Does something with the clean_data and returns an HttpResponseRedirect." 
     163    def done(self, request, cleaned_data): 
     164        """ 
     165        Does something with the cleaned_data and returns an 
     166        HttpResponseRedirect. 
     167        """ 
    165168        raise NotImplementedError('You must define a done() method on your %s subclass.' % self.__class__.__name__) 
  • django/branches/newforms-admin/django/contrib/localflavor/is_/forms.py

    r5195 r5244  
    4242        """ 
    4343        check = [3, 2, 7, 6, 5, 4, 3, 2, 1, 0] 
    44         return sum(int(value[i]) * check[i] for i in range(10)) % 11 == 0 
     44        return sum([int(value[i]) * check[i] for i in range(10)]) % 11 == 0 
    4545 
    4646    def _format(self, value): 
  • django/branches/newforms-admin/django/core/management.py

    r5195 r5244  
    14081408                        print "No %s fixture '%s' in %s." % \ 
    14091409                            (format, fixture_name, humanize(fixture_dir)) 
     1410                             
     1411    if count[0] > 0: 
     1412        sequence_sql = backend.get_sql_sequence_reset(style, models) 
     1413        if sequence_sql: 
     1414            if verbosity > 1: 
     1415                print "Resetting sequences" 
     1416            for line in sequence_sql: 
     1417                cursor.execute(line) 
     1418             
     1419    transaction.commit() 
     1420    transaction.leave_transaction_management() 
     1421     
    14101422    if count[0] == 0: 
    14111423        if verbosity > 0: 
     
    14141426        if verbosity > 0: 
    14151427            print "Installed %d object(s) from %d fixture(s)" % tuple(count) 
    1416         sequence_sql = backend.get_sql_sequence_reset(style, models) 
    1417         if sequence_sql: 
    1418             if verbosity > 1: 
    1419                 print "Resetting sequences" 
    1420             for line in sequence_sql: 
    1421                 cursor.execute(line) 
    1422     transaction.commit() 
    1423     transaction.leave_transaction_management() 
    14241428 
    14251429load_data.help_doc = 'Installs the named fixture(s) in the database' 
  • django/branches/newforms-admin/django/core/serializers/python.py

    r4750 r5244  
    3838        related = getattr(obj, field.name) 
    3939        if related is not None: 
    40             related = related._get_pk_val(
     40            related = getattr(related, field.rel.field_name
    4141        self._current[field.name] = related 
    4242     
     
    8181            # Handle FK fields 
    8282            elif field.rel and isinstance(field.rel, models.ManyToOneRel): 
    83                 data[field.attname] = field.rel.to._meta.pk.to_python(field_value) 
     83                if field_value: 
     84                    data[field.attname] = field.rel.to._meta.get_field(field.rel.field_name).to_python(field_value) 
     85                else: 
     86                    data[field.attname] = None 
    8487                     
    8588            # Handle all other fields 
  • django/branches/newforms-admin/django/core/serializers/xml_serializer.py

    r4750 r5244  
    8383        related = getattr(obj, field.name) 
    8484        if related is not None: 
    85             self.xml.characters(str(related._get_pk_val())) 
     85            self.xml.characters(str(getattr(related, field.rel.field_name))) 
    8686        else: 
    8787            self.xml.addQuickElement("None") 
     
    182182            return None 
    183183        else: 
    184             return field.rel.to._meta.pk.to_python( 
     184            return field.rel.to._meta.get_field(field.rel.field_name).to_python( 
    185185                       getInnerText(node).strip().encode(self.encoding)) 
    186186         
  • django/branches/newforms-admin/django/db/backends/postgresql/base.py

    r5195 r5244  
    224224                output.append("%s setval('%s', (%s max(%s) %s %s));" % \ 
    225225                    (style.SQL_KEYWORD('SELECT'), 
    226                     style.SQL_FIELD('%s_%s_seq' % (model._meta.db_table, f.column)), 
     226                    style.SQL_FIELD(quote_name('%s_%s_seq' % (model._meta.db_table, f.column))), 
    227227                    style.SQL_KEYWORD('SELECT'), 
    228228                    style.SQL_FIELD(quote_name(f.column)), 
     
    233233            output.append("%s setval('%s', (%s max(%s) %s %s));" % \ 
    234234                (style.SQL_KEYWORD('SELECT'), 
    235                 style.SQL_FIELD('%s_id_seq' % f.m2m_db_table()), 
     235                style.SQL_FIELD(quote_name('%s_id_seq' % f.m2m_db_table())), 
    236236                style.SQL_KEYWORD('SELECT'), 
    237237                style.SQL_FIELD(quote_name('id')), 
  • django/branches/newforms-admin/django/db/backends/postgresql_psycopg2/base.py

    r5195 r5244  
    181181                output.append("%s setval('%s', (%s max(%s) %s %s));" % \ 
    182182                    (style.SQL_KEYWORD('SELECT'), 
    183                     style.SQL_FIELD('%s_%s_seq' % (model._meta.db_table, f.column)), 
     183                    style.SQL_FIELD(quote_name('%s_%s_seq' % (model._meta.db_table, f.column))), 
    184184                    style.SQL_KEYWORD('SELECT'), 
    185185                    style.SQL_FIELD(quote_name(f.column)), 
     
    190190            output.append("%s setval('%s', (%s max(%s) %s %s));" % \ 
    191191                (style.SQL_KEYWORD('SELECT'), 
    192                 style.SQL_FIELD('%s_id_seq' % f.m2m_db_table()), 
     192                style.SQL_FIELD(quote_name('%s_id_seq' % f.m2m_db_table())), 
    193193                style.SQL_KEYWORD('SELECT'), 
    194194                style.SQL_FIELD(quote_name('id')), 
  • django/branches/newforms-admin/django/newforms/formsets.py

    r4953 r5244  
    3434            self.management_form = ManagementForm(data, auto_id=self.auto_id, prefix=self.prefix) 
    3535            if self.management_form.is_valid(): 
    36                 self.total_forms = self.management_form.clean_data[FORM_COUNT_FIELD_NAME] 
     36                self.total_forms = self.management_form.cleaned_data[FORM_COUNT_FIELD_NAME] 
    3737                self.required_forms = self.total_forms - self.num_extra 
    3838            else: 
     
    6868    def full_clean(self): 
    6969        """ 
    70         Cleans all of self.data and populates self.__errors and self.clean_data. 
     70        Cleans all of self.data and populates self.__errors and self.cleaned_data. 
    7171        """ 
    7272        is_valid = True 
     
    7676            self.__errors = errors 
    7777            return 
    78         clean_data = [] 
     78        cleaned_data = [] 
    7979        deleted_data = [] 
    8080         
     
    104104            else: 
    105105                # if the formset is still vaild overall and this form instance 
    106                 # is valid, keep appending to clean_data 
     106                # is valid, keep appending to cleaned_data 
    107107                if is_valid and form.is_valid(): 
    108                     if self.deletable and form.clean_data[DELETION_FIELD_NAME]: 
    109                         deleted_data.append(form.clean_data) 
     108                    if self.deletable and form.cleaned_data[DELETION_FIELD_NAME]: 
     109                        deleted_data.append(form.cleaned_data) 
    110110                    else: 
    111                         clean_data.append(form.clean_data) 
     111                        cleaned_data.append(form.cleaned_data) 
    112112                else: 
    113113                    is_valid = False 
     
    118118        deleted_data.reverse() 
    119119        if self.orderable: 
    120             clean_data.sort(lambda x,y: x[ORDERING_FIELD_NAME] - y[ORDERING_FIELD_NAME]) 
     120            cleaned_data.sort(lambda x,y: x[ORDERING_FIELD_NAME] - y[ORDERING_FIELD_NAME]) 
    121121        else: 
    122             clean_data.reverse() 
     122            cleaned_data.reverse() 
    123123        errors.reverse() 
    124124        self._form_list.reverse() 
    125125         
    126126        if is_valid: 
    127             self.clean_data = clean_data 
     127            self.cleaned_data = cleaned_data 
    128128            self.deleted_data = deleted_data 
    129129        self.errors = errors 
  • django/branches/newforms-admin/django/newforms/forms.py

    r5195 r5244  
    188188    def full_clean(self): 
    189189        """ 
    190         Cleans all of self.data and populates self.__errors and self.clean_data. 
     190        Cleans all of self.data and populates self.__errors and self.cleaned_data. 
    191191        """ 
    192192        errors = ErrorDict() 
     
    194194            self.__errors = errors 
    195195            return 
    196         self.clean_data = {} 
     196        self.cleaned_data = {} 
    197197        for name, field in self.fields.items(): 
    198198            # value_from_datadict() gets the data from the dictionary. 
     
    202202            try: 
    203203                value = field.clean(value) 
    204                 self.clean_data[name] = value 
     204                self.cleaned_data[name] = value 
    205205                if hasattr(self, 'clean_%s' % name): 
    206206                    value = getattr(self, 'clean_%s' % name)() 
    207                 self.clean_data[name] = value 
     207                self.cleaned_data[name] = value 
    208208            except ValidationError, e: 
    209209                errors[name] = e.messages 
    210210        try: 
    211             self.clean_data = self.clean() 
     211            self.cleaned_data = self.clean() 
    212212        except ValidationError, e: 
    213213            errors[NON_FIELD_ERRORS] = e.messages 
    214214        if errors: 
    215             delattr(self, 'clean_data') 
     215            delattr(self, 'cleaned_data') 
    216216        self.__errors = errors 
    217217 
     
    223223        association with the field named '__all__'. 
    224224        """ 
    225         return self.clean_data 
     225        return self.cleaned_data 
    226226 
    227227class Form(BaseForm): 
     
    274274        if not self.form.is_bound: 
    275275            data = self.form.initial.get(self.name, self.field.initial) 
     276            if callable(data): 
     277                data = data() 
    276278        else: 
    277279            data = self.data 
  • django/branches/newforms-admin/django/newforms/models.py

    r4940 r5244  
    1313           'ModelChoiceField', 'ModelMultipleChoiceField') 
    1414 
    15 def model_save(self, commit=True): 
     15def save_instance(form, instance, fields=None, fail_message='saved', commit=True): 
    1616    """ 
    17     Creates and returns model instance according to self.clean_data. 
    18  
    19     This method is created for any form_for_model Form. 
    20     """ 
    21     if self.errors: 
    22         raise ValueError("The %s could not be created because the data didn't validate." % self._model._meta.object_name) 
    23     return save_instance(self, self._model(), commit) 
    24  
    25 def save_instance(form, instance, commit=True): 
    26     """ 
    27     Saves bound Form ``form``'s clean_data into model instance ``instance``. 
     17    Saves bound Form ``form``'s cleaned_data into model instance ``instance``. 
    2818 
    2919    Assumes ``form`` has a field for every non-AutoField database field in 
     
    3424    opts = instance.__class__._meta 
    3525    if form.errors: 
    36         raise ValueError("The %s could not be changed because the data didn't validate." % opts.object_name
    37     clean_data = form.clean_data 
     26        raise ValueError("The %s could not be %s because the data didn't validate." % (opts.object_name, fail_message)
     27    cleaned_data = form.cleaned_data 
    3828    for f in opts.fields: 
    39         if not f.editable or isinstance(f, models.AutoField) or not f.name in clean_data: 
     29        if not f.editable or isinstance(f, models.AutoField) or not f.name in cleaned_data: 
    4030            continue 
    41         setattr(instance, f.name, clean_data[f.name]) 
     31        if fields and f.name not in fields: 
     32            continue 
     33        setattr(instance, f.name, cleaned_data[f.name]) 
    4234    if commit: 
    4335        instance.save() 
    4436        for f in opts.many_to_many: 
    45             if f.name in clean_data: 
    46                 setattr(instance, f.attname, clean_data[f.name]) 
     37            if fields and f.name not in fields: 
     38                continue 
     39            if f.name in cleaned_data: 
     40                setattr(instance, f.attname, cleaned_data[f.name]) 
    4741    # GOTCHA: If many-to-many data is given and commit=False, the many-to-many 
    4842    # data will be lost. This happens because a many-to-many options cannot be 
     
    5145    return instance 
    5246 
    53 def make_instance_save(instance): 
    54     "Returns the save() method for a form_for_instance Form." 
     47def make_model_save(model, fields, fail_message): 
     48    "Returns the save() method for a Form." 
    5549    def save(self, commit=True): 
    56         return save_instance(self, instance, commit) 
     50        return save_instance(self, model(), fields, fail_message, commit) 
     51    return save 
     52     
     53def make_instance_save(instance, fields, fail_message): 
     54    "Returns the save() method for a Form." 
     55    def save(self, commit=True): 
     56        return save_instance(self, instance, fields, fail_message, commit) 
    5757    return save 
    5858 
    59 def form_for_model(model, form=BaseForm, formfield_callback=lambda f: f.formfield()): 
     59def form_for_model(model, form=BaseForm, fields=None, formfield_callback=lambda f: f.formfield()): 
    6060    """ 
    6161    Returns a Form class for the given Django model class. 
     
    7272        if not f.editable: 
    7373            continue 
     74        if fields and not f.name in fields: 
     75            continue 
    7476        formfield = formfield_callback(f) 
    7577        if formfield: 
    7678            field_list.append((f.name, formfield)) 
    77     fields = SortedDictFromList(field_list) 
    78     return type(opts.object_name + 'Form', (form,), {'base_fields': fields, '_model': model, 'save': model_save}) 
     79    base_fields = SortedDictFromList(field_list) 
     80    return type(opts.object_name + 'Form', (form,),  
     81        {'base_fields': base_fields, '_model': model, 'save': make_model_save(model, fields, 'created')}) 
    7982 
    80 def form_for_instance(instance, form=BaseForm, formfield_callback=lambda f, **kwargs: f.formfield(**kwargs)): 
     83def form_for_instance(instance, form=BaseForm, fields=None, formfield_callback=lambda f, **kwargs: f.formfield(**kwargs)): 
    8184    """ 
    8285    Returns a Form class for the given Django model instance. 
     
    9598        if not f.editable: 
    9699            continue 
     100        if fields and not f.name in fields: 
     101            continue 
    97102        current_value = f.value_from_object(instance) 
    98103        formfield = formfield_callback(f, initial=current_value) 
    99104        if formfield: 
    100105            field_list.append((f.name, formfield)) 
    101     fields = SortedDictFromList(field_list) 
     106    base_fields = SortedDictFromList(field_list) 
    102107    return type(opts.object_name + 'InstanceForm', (form,), 
    103         {'base_fields': fields, '_model': model, 'save': make_instance_save(instance)}) 
     108        {'base_fields': base_fields, '_model': model, 'save': make_instance_save(instance, fields, 'changed')}) 
    104109 
    105110def form_for_fields(field_list): 
  • django/branches/newforms-admin/django/test/testcases.py

    r5195 r5244  
    4646            management.load_data(self.fixtures, verbosity=0) 
    4747        mail.outbox = [] 
    48          
    49     def run(self, result=None): 
    50         """Wrapper around default run method to perform common Django test set up. 
    51         This means that user-defined Test Cases aren't required to include a call  
    52         to super().setUp(). 
    53          
     48 
     49    def __call__(self, result=None): 
     50        """ 
     51        Wrapper around default __call__ method to perform common Django test 
     52        set up. This means that user-defined Test Cases aren't required to 
     53        include a call to super().setUp(). 
    5454        """ 
    5555        self.client = Client() 
    5656        self._pre_setup() 
    57         super(TestCase, self).run(result) 
     57        super(TestCase, self).__call__(result) 
    5858 
    5959    def assertRedirects(self, response, expected_path, status_code=302, target_status_code=200): 
     
    6363        """ 
    6464        self.assertEqual(response.status_code, status_code,  
    65             "Response didn't redirect: Reponse code was %d (expected %d)" %  
     65            "Response didn't redirect as expected: Reponse code was %d (expected %d)" %  
    6666                (response.status_code, status_code)) 
    6767        scheme, netloc, path, params, query, fragment = urlparse(response['Location']) 
     
    7171        self.assertEqual(redirect_response.status_code, target_status_code,  
    7272            "Couldn't retrieve redirection page '%s': response code was %d (expected %d)" %  
    73                 (path, response.status_code, status_code)) 
     73                (path, redirect_response.status_code, target_status_code)) 
    7474     
    7575    def assertContains(self, response, text, count=1, status_code=200): 
     
    109109                    if field: 
    110110                        if field in context[form].errors: 
    111                             self.assertTrue(err in context[form].errors[field],  
     111                            self.failUnless(err in context[form].errors[field],  
    112112                            "The field '%s' on form '%s' in context %d does not contain the error '%s' (actual errors: %s)" %  
    113113                                (field, form, i, err, list(context[form].errors[field]))) 
     
    118118                            self.fail("The form '%s' in context %d does not contain the field '%s'" % (form, i, field)) 
    119119                    else: 
    120                         self.assertTrue(err in context[form].non_field_errors(),  
     120                        self.failUnless(err in context[form].non_field_errors(),  
    121121                            "The form '%s' in context %d does not contain the non-field error '%s' (actual errors: %s)" %  
    122122                                (form, i, err, list(context[form].non_field_errors()))) 
     
    128128        if isinstance(response.template, list): 
    129129            template_names = [t.name for t in response.template] 
    130             self.assertTrue(template_name in template_names, 
     130            self.failUnless(template_name in template_names, 
    131131                "Template '%s' was not one of the templates used to render the response. Templates used: %s" % 
    132132                    (template_name, template_names)) 
     
    141141        "Assert that the template with the provided name was NOT used in rendering the response" 
    142142        if isinstance(response.template, list):             
    143             self.assertFalse(template_name in [t.name for t in response.template], 
     143            self.failIf(template_name in [t.name for t in response.template], 
    144144                "Template '%s' was used unexpectedly in rendering the response" % template_name) 
    145145        elif response.template: 
  • django/branches/newforms-admin/docs/databrowse.txt

    r5195 r5244  
    4545       some point. A good place for it is in your URLconf file (``urls.py``). 
    4646 
    47     3. Add the following line to your URLconf:: 
     47    3. Change your URLconf to import the ``databrowse`` module:: 
     48 
     49           from django.contrib import databrowse 
     50 
     51       ...and add the following line to your URLconf:: 
    4852 
    4953           (r'^databrowse/(.*)', databrowse.site.root), 
  • django/branches/newforms-admin/docs/i18n.txt

    r5195 r5244  
    237237``{% endblocktrans %}``. Example:: 
    238238 
    239     {% blocktrans count list|count as counter %} 
     239    {% blocktrans count list|length as counter %} 
    240240    There is only one {{ name }} object. 
    241241    {% plural %} 
  • django/branches/newforms-admin/docs/newforms.txt

    r4824 r5244  
    1010============== 
    1111 
    12 ``django.newforms`` currently is only available in Django beginning 
    13 with the 0.96 release.  the Django development version -- i.e., it's 
    14 not available in the Django 0.95 release. For the next Django release, 
    15 our plan is to do the following: 
    16  
    17     * As of revision [4208], we've copied the current ``django.forms`` to 
    18       ``django.oldforms``. This allows you to upgrade your code *now* rather 
    19       than waiting for the backwards-incompatible change and rushing to fix 
    20       your code after the fact. Just change your import statements like this:: 
     12``django.newforms`` is new in Django's 0.96 release, but, as it won't be new 
     13forever, we plan to rename it to ``django.forms`` in the future. The current 
     14``django.forms`` package will be available as ``django.oldforms`` until Django 
     151.0, when we plan to remove it for good. 
     16 
     17That has direct repercussions on the forward compatibility of your code. Please 
     18read the following migration plan and code accordingly: 
     19 
     20    * The old forms framework (the current ``django.forms``) has been copied to 
     21      ``django.oldforms``. Thus, you can start upgrading your code *now*, 
     22      rather than waiting for the future backwards-incompatible change, by 
     23      changing your import statements like this:: 
    2124 
    2225          from django import forms             # old 
    2326          from django import oldforms as forms # new 
    2427 
    25     * At an undecided future date, we will move the current ``django.newforms`` 
    26       to ``django.forms``. This will be a backwards-incompatible change, and 
    27       anybody who is still using the old version of ``django.forms`` at that 
    28       time will need to change their import statements, as described in the 
    29       previous bullet. 
     28    * In the next Django release (0.97), we will move the current 
     29      ``django.newforms`` to ``django.forms``. This will be a 
     30      backwards-incompatible change, and anybody who is still using the old 
     31      version of ``django.forms`` at that time will need to change their import 
     32      statements, as described in the previous bullet. 
    3033 
    3134    * We will remove ``django.oldforms`` in the release *after* the next Django 
    32       release -- the release that comes after the release in which we're 
    33       creating the new ``django.forms``. 
     35      release -- either 0.98 or 1.0, whichever comes first. 
    3436 
    3537With this in mind, we recommend you use the following import statement when 
     
    185187    False 
    186188 
    187 Access the ``Form`` attribute ``errors`` to get a dictionary of error messages:: 
     189Access the ``errors`` attribute to get a dictionary of error messages:: 
    188190 
    189191    >>> f.errors 
     
    197199form's data will be validated the first time either you call ``is_valid()`` or 
    198200access ``errors``. 
     201 
     202The validation routines will only get called once, regardless of how many times 
     203you access ``errors`` or call ``is_valid()``. This means that if validation has 
     204side effects, those side effects will only be triggered once. 
    199205 
    200206Behavior of unbound forms 
     
    225231 
    226232Once you've created a ``Form`` instance with a set of data and validated it, 
    227 you can access the clean data via the ``clean_data`` attribute of the ``Form`` 
     233you can access the clean data via the ``cleaned_data`` attribute of the ``Form`` 
    228234object:: 
    229235 
     
    235241    >>> f.is_valid() 
    236242    True 
    237     >>> f.clean_data 
     243    >>> f.cleaned_data 
    238244    {'cc_myself': True, 'message': u'Hi there', 'sender': u'foo@example.com', 'subject': u'hello'} 
    239245 
     
    243249 
    244250If your data does *not* validate, your ``Form`` instance will not have a 
    245 ``clean_data`` attribute:: 
     251``cleaned_data`` attribute:: 
    246252 
    247253    >>> data = {'subject': '', 
     
    252258    >>> f.is_valid() 
    253259    False 
    254     >>> f.clean_data 
     260    >>> f.cleaned_data 
    255261    Traceback (most recent call last): 
    256262    ... 
    257     AttributeError: 'ContactForm' object has no attribute 'clean_data' 
    258  
    259 ``clean_data`` will always *only* contain a key for fields defined in the 
     263    AttributeError: 'ContactForm' object has no attribute 'cleaned_data' 
     264 
     265``cleaned_data`` will always *only* contain a key for fields defined in the 
    260266``Form``, even if you pass extra data when you define the ``Form``. In this 
    261267example, we pass a bunch of extra fields to the ``ContactForm`` constructor, 
    262 but ``clean_data`` contains only the form's fields:: 
     268but ``cleaned_data`` contains only the form's fields:: 
    263269 
    264270    >>> data = {'subject': 'hello', 
     
    272278    >>> f.is_valid() 
    273279    True 
    274     >>> f.clean_data # Doesn't contain extra_field_1, etc. 
     280    >>> f.cleaned_data # Doesn't contain extra_field_1, etc. 
    275281    {'cc_myself': True, 'message': u'Hi there', 'sender': u'foo@example.com', 'subject': u'hello'} 
     282 
     283``cleaned_data`` will include a key and value for *all* fields defined in the 
     284``Form``, even if the data didn't include a value for fields that are not 
     285required. In this example, the data dictionary doesn't include a value for the 
     286``nick_name`` field, but ``cleaned_data`` includes it, with an empty value:: 
     287 
     288    >>> class OptionalPersonForm(Form): 
     289    ...     first_name = CharField() 
     290    ...     last_name = CharField() 
     291    ...     nick_name = CharField(required=False) 
     292    >>> data = {'first_name': u'John', 'last_name': u'Lennon'} 
     293    >>> f = OptionalPersonForm(data) 
     294    >>> f.is_valid() 
     295    True 
     296    >>> f.cleaned_data 
     297    {'nick_name': u'', 'first_name': u'John', 'last_name': u'Lennon'} 
     298 
     299In this above example, the ``cleaned_data`` value for ``nick_name`` is set to an 
     300empty string, because ``nick_name`` is ``CharField``, and ``CharField``\s treat 
     301empty values as an empty string. Each field type knows what its "blank" value 
     302is -- e.g., for ``DateField``, it's ``None`` instead of the empty string. 
    276303 
    277304Behavior of unbound forms 
     
    282309 
    283310    >>> f = ContactForm() 
    284     >>> f.clean_data 
     311    >>> f.cleaned_data 
    285312    Traceback (most recent call last): 
    286313    ... 
    287     AttributeError: 'ContactForm' object has no attribute 'clean_data' 
     314    AttributeError: 'ContactForm' object has no attribute 'cleaned_data' 
    288315 
    289316Outputting forms as HTML 
     
    455482then the form output will include ``<label>`` tags, and will generate ``id`` 
    456483attributes based on the format string. For example, for a format string 
    457 ``'field_%s'``, a field named ``subject`` will get the ``id`` 
     484``'field_%s'``, a field named ``subject`` will get the ``id`` value 
    458485``'field_subject'``. Continuing our example:: 
    459486 
     
    494521If you render a bound ``Form`` object, the act of rendering will automatically 
    495522run the form's validation if it hasn't already happened, and the HTML output 
    496 will include the validation errors as a ``<ul>`` near the field. The particular 
    497 positioning of the error messages depends on the output method you're using:: 
     523will include the validation errors as a ``<ul class="errorlist">`` near the 
     524field. The particular positioning of the error messages depends on the output 
     525method you're using:: 
    498526 
    499527    >>> data = {'subject': '', 
     
    557585 
    558586For a field's list of errors, access the field's ``errors`` attribute. This 
    559 is a list-like object that is displayed as an HTML ``<ul>`` when printed:: 
     587is a list-like object that is displayed as an HTML ``<ul class="errorlist">`` 
     588when printed:: 
    560589 
    561590    >>> data = {'subject': 'hi', 'message': '', 'sender': '', 'cc_myself': ''} 
     
    647676Each ``Field`` class constructor takes at least these arguments. Some 
    648677``Field`` classes take additional, field-specific arguments, but the following 
    649 should *always* be available
     678should *always* be accepted
    650679 
    651680``required`` 
     
    705734field. This is used when the ``Field`` is displayed in a ``Form``. 
    706735 
    707 As explained in _`Outputting forms as HTML` above, the default label for a 
     736As explained in "Outputting forms as HTML" above, the default label for a 
    708737``Field`` is generated from the field name by converting all underscores to 
    709738spaces and upper-casing the first letter. Specify ``label`` if that default 
     
    780809 
    781810The ``widget`` argument lets you specify a ``Widget`` class to use when 
    782 rendering this ``Field``. See _`Widgets` below for more information. 
     811rendering this ``Field``. See "Widgets" below for more information. 
    783812 
    784813``help_text`` 
     
    787816The ``help_text`` argument lets you specify descriptive text for this 
    788817``Field``. If you provide ``help_text``, it will be displayed next to the 
    789 ``Field`` when the ``Field`` is rendered in a ``Form``. 
     818``Field`` when the ``Field`` is rendered by one of the convenience ``Form`` 
     819methods (e.g., ``as_ul()``). 
    790820 
    791821Here's a full example ``Form`` that implements ``help_text`` for two of its 
     
    861891    <tr><th>Comment:</th><td><input type="text" name="comment" /></td></tr> 
    862892 
     893Built-in ``Field`` classes 
     894-------------------------- 
     895 
     896Naturally, the ``newforms`` library comes with a set of ``Field`` classes that 
     897represent common validation needs. This section documents each built-in field. 
     898 
     899For each field, we describe the default widget used if you don't specify 
     900``widget``. We also specify the value returned when you provide an empty value 
     901(see the section on ``required`` above to understand what that means). 
     902 
     903``BooleanField`` 
     904~~~~~~~~~~~~~~~~ 
     905 
     906    * Default widget: ``CheckboxInput`` 
     907    * Empty value: ``None`` 
     908    * Normalizes to: A Python ``True`` or ``False`` value. 
     909    * Validates nothing (i.e., it never raises a ``ValidationError``). 
     910 
     911``CharField`` 
     912~~~~~~~~~~~~~ 
     913 
     914    * Default widget: ``TextInput`` 
     915    * Empty value: ``''`` (an empty string) 
     916    * Normalizes to: A Unicode object. 
     917    * Validates nothing, unless ``max_length`` or ``min_length`` is provided. 
     918 
     919Has two optional arguments for validation, ``max_length`` and ``min_length``. 
     920If provided, these arguments ensure that the string is at most or at least the 
     921given length. 
     922 
     923``ChoiceField`` 
     924~~~~~~~~~~~~~~~ 
     925 
     926    * Default widget: ``Select`` 
     927    * Empty value: ``''`` (an empty string) 
     928    * Normalizes to: A Unicode object. 
     929    * Validates that the given value exists in the list of choices. 
     930 
     931Takes one extra argument, ``choices``, which is an iterable (e.g., a list or 
     932tuple) of 2-tuples to use as choices for this field. 
     933 
     934``DateField`` 
     935~~~~~~~~~~~~~ 
     936 
     937    * Default widget: ``TextInput`` 
     938    * Empty value: ``None`` 
     939    * Normalizes to: A Python ``datetime.date`` object. 
     940    * Validates that the given value is either a ``datetime.date``, 
     941      ``datetime.datetime`` or string formatted in a particular date format. 
     942 
     943Takes one optional argument, ``input_formats``, which is a list of formats used 
     944to attempt to convert a string to a valid ``datetime.date`` object. 
     945 
     946If no ``input_formats`` argument is provided, the default input formats are:: 
     947 
     948    '%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06' 
     949    '%b %d %Y', '%b %d, %Y',            # 'Oct 25 2006', 'Oct 25, 2006' 
     950    '%d %b %Y', '%d %b, %Y',            # '25 Oct 2006', '25 Oct, 2006' 
     951    '%B %d %Y', '%B %d, %Y',            # 'October 25 2006', 'October 25, 2006' 
     952    '%d %B %Y', '%d %B, %Y',            # '25 October 2006', '25 October, 2006' 
     953 
     954``DateTimeField``&nbs