Django

Code

Ticket #4975: label_colon_removal.patch

File label_colon_removal.patch, 90.3 kB (added by gnuvince, 1 year ago)
  • django/newforms/forms.py

    old new  
    129129                    output.append(error_row % force_unicode(bf_errors)) 
    130130                if bf.label: 
    131131                    label = escape(force_unicode(bf.label)) 
    132                     # Only add a colon if the label does not end in punctuation. 
    133                     if label[-1] not in ':?.!': 
    134                         label += ':' 
    135132                    label = bf.label_tag(label) or '' 
    136133                else: 
    137134                    label = '' 
  • tests/modeltests/model_forms/models.py

    old new  
    8080>>> CategoryForm = form_for_model(Category) 
    8181>>> f = CategoryForm() 
    8282>>> print f 
    83 <tr><th><label for="id_name">Name:</label></th><td><input id="id_name" type="text" name="name" maxlength="20" /></td></tr> 
    84 <tr><th><label for="id_slug">Slug:</label></th><td><input id="id_slug" type="text" name="slug" maxlength="20" /></td></tr> 
    85 <tr><th><label for="id_url">The URL:</label></th><td><input id="id_url" type="text" name="url" maxlength="40" /></td></tr> 
     83<tr><th><label for="id_name">Name</label></th><td><input id="id_name" type="text" name="name" maxlength="20" /></td></tr> 
     84<tr><th><label for="id_slug">Slug</label></th><td><input id="id_slug" type="text" name="slug" maxlength="20" /></td></tr> 
     85<tr><th><label for="id_url">The URL</label></th><td><input id="id_url" type="text" name="url" maxlength="40" /></td></tr> 
    8686>>> print f.as_ul() 
    87 <li><label for="id_name">Name:</label> <input id="id_name" type="text" name="name" maxlength="20" /></li> 
    88 <li><label for="id_slug">Slug:</label> <input id="id_slug" type="text" name="slug" maxlength="20" /></li> 
    89 <li><label for="id_url">The URL:</label> <input id="id_url" type="text" name="url" maxlength="40" /></li> 
     87<li><label for="id_name">Name</label> <input id="id_name" type="text" name="name" maxlength="20" /></li> 
     88<li><label for="id_slug">Slug</label> <input id="id_slug" type="text" name="slug" maxlength="20" /></li> 
     89<li><label for="id_url">The URL</label> <input id="id_url" type="text" name="url" maxlength="40" /></li> 
    9090>>> print f['name'] 
    9191<input id="id_name" type="text" name="name" maxlength="20" /> 
    9292 
    9393>>> f = CategoryForm(auto_id=False) 
    9494>>> print f.as_ul() 
    95 <li>Name: <input type="text" name="name" maxlength="20" /></li> 
    96 <li>Slug: <input type="text" name="slug" maxlength="20" /></li> 
    97 <li>The URL: <input type="text" name="url" maxlength="40" /></li> 
     95<li>Name <input type="text" name="name" maxlength="20" /></li> 
     96<li>Slug <input type="text" name="slug" maxlength="20" /></li> 
     97<li>The URL <input type="text" name="url" maxlength="40" /></li> 
    9898 
    9999>>> f = CategoryForm({'name': 'Entertainment', 'slug': 'entertainment', 'url': 'entertainment'}) 
    100100>>> f.is_valid() 
     
    164164>>> ArticleForm = form_for_model(Article) 
    165165>>> f = ArticleForm(auto_id=False) 
    166166>>> print f 
    167 <tr><th>Headline:</th><td><input type="text" name="headline" maxlength="50" /></td></tr> 
    168 <tr><th>Slug:</th><td><input type="text" name="slug" maxlength="50" /></td></tr> 
    169 <tr><th>Pub date:</th><td><input type="text" name="pub_date" /></td></tr> 
    170 <tr><th>Writer:</th><td><select name="writer"> 
     167<tr><th>Headline</th><td><input type="text" name="headline" maxlength="50" /></td></tr> 
     168<tr><th>Slug</th><td><input type="text" name="slug" maxlength="50" /></td></tr> 
     169<tr><th>Pub date</th><td><input type="text" name="pub_date" /></td></tr> 
     170<tr><th>Writer</th><td><select name="writer"> 
    171171<option value="" selected="selected">---------</option> 
    172172<option value="1">Mike Royko</option> 
    173173<option value="2">Bob Woodward</option> 
    174174</select></td></tr> 
    175 <tr><th>Article:</th><td><textarea rows="10" cols="40" name="article"></textarea></td></tr> 
    176 <tr><th>Status:</th><td><select name="status"> 
     175<tr><th>Article</th><td><textarea rows="10" cols="40" name="article"></textarea></td></tr> 
     176<tr><th>Status</th><td><select name="status"> 
    177177<option value="" selected="selected">---------</option> 
    178178<option value="1">Draft</option> 
    179179<option value="2">Pending</option> 
    180180<option value="3">Live</option> 
    181181</select></td></tr> 
    182 <tr><th>Categories:</th><td><select multiple="multiple" name="categories"> 
     182<tr><th>Categories</th><td><select multiple="multiple" name="categories"> 
    183183<option value="1">Entertainment</option> 
    184184<option value="2">It&#39;s a test</option> 
    185185<option value="3">Third test</option> 
     
    194194>>> PartialArticleForm = form_for_model(Article, fields=('headline','pub_date')) 
    195195>>> f = PartialArticleForm(auto_id=False) 
    196196>>> print f 
    197 <tr><th>Headline:</th><td><input type="text" name="headline" maxlength="50" /></td></tr> 
    198 <tr><th>Pub date:</th><td><input type="text" name="pub_date" /></td></tr> 
     197<tr><th>Headline</th><td><input type="text" name="headline" maxlength="50" /></td></tr> 
     198<tr><th>Pub date</th><td><input type="text" name="pub_date" /></td></tr> 
    199199 
    200200You can pass a custom Form class to form_for_model. Make sure it's a 
    201201subclass of BaseForm, not Form. 
     
    214214>>> RoykoForm = form_for_instance(w) 
    215215>>> f = RoykoForm(auto_id=False) 
    216216>>> print f 
    217 <tr><th>Name:</th><td><input type="text" name="name" value="Mike Royko" maxlength="50" /><br />Use both first and last names.</td></tr> 
     217<tr><th>Name</th><td><input type="text" name="name" value="Mike Royko" maxlength="50" /><br />Use both first and last names.</td></tr> 
    218218 
    219219>>> art = Article(headline='Test article', slug='test-article', pub_date=datetime.date(1988, 1, 4), writer=w, article='Hello.') 
    220220>>> art.save() 
     
    223223>>> TestArticleForm = form_for_instance(art) 
    224224>>> f = TestArticleForm(auto_id=False) 
    225225>>> print f.as_ul() 
    226 <li>Headline: <input type="text" name="headline" value="Test article" maxlength="50" /></li> 
    227 <li>Slug: <input type="text" name="slug" value="test-article" maxlength="50" /></li> 
    228 <li>Pub date: <input type="text" name="pub_date" value="1988-01-04" /></li> 
    229 <li>Writer: <select name="writer"> 
     226<li>Headline <input type="text" name="headline" value="Test article" maxlength="50" /></li> 
     227<li>Slug <input type="text" name="slug" value="test-article" maxlength="50" /></li> 
     228<li>Pub date <input type="text" name="pub_date" value="1988-01-04" /></li> 
     229<li>Writer <select name="writer"> 
    230230<option value="">---------</option> 
    231231<option value="1" selected="selected">Mike Royko</option> 
    232232<option value="2">Bob Woodward</option> 
    233233</select></li> 
    234 <li>Article: <textarea rows="10" cols="40" name="article">Hello.</textarea></li> 
    235 <li>Status: <select name="status"> 
     234<li>Article <textarea rows="10" cols="40" name="article">Hello.</textarea></li> 
     235<li>Status <select name="status"> 
    236236<option value="" selected="selected">---------</option> 
    237237<option value="1">Draft</option> 
    238238<option value="2">Pending</option> 
    239239<option value="3">Live</option> 
    240240</select></li> 
    241 <li>Categories: <select multiple="multiple" name="categories"> 
     241<li>Categories <select multiple="multiple" name="categories"> 
    242242<option value="1">Entertainment</option> 
    243243<option value="2">It&#39;s a test</option> 
    244244<option value="3">Third test</option> 
     
    258258>>> PartialArticleForm = form_for_instance(art, fields=('headline', 'slug', 'pub_date')) 
    259259>>> f = PartialArticleForm({'headline': u'New headline', 'slug': 'new-headline', 'pub_date': u'1988-01-04'}, auto_id=False) 
    260260>>> print f.as_ul() 
    261 <li>Headline: <input type="text" name="headline" value="New headline" maxlength="50" /></li> 
    262 <li>Slug: <input type="text" name="slug" value="new-headline" maxlength="50" /></li> 
    263 <li>Pub date: <input type="text" name="pub_date" value="1988-01-04" /></li> 
     261<li>Headline <input type="text" name="headline" value="New headline" maxlength="50" /></li> 
     262<li>Slug <input type="text" name="slug" value="new-headline" maxlength="50" /></li> 
     263<li>Pub date <input type="text" name="pub_date" value="1988-01-04" /></li> 
    264264>>> f.is_valid() 
    265265True 
    266266>>> new_art = f.save() 
     
    279279>>> TestArticleForm = form_for_instance(new_art) 
    280280>>> f = TestArticleForm(auto_id=False) 
    281281>>> print f.as_ul() 
    282 <li>Headline: <input type="text" name="headline" value="New headline" maxlength="50" /></li> 
    283 <li>Slug: <input type="text" name="slug" value="new-headline" maxlength="50" /></li> 
    284 <li>Pub date: <input type="text" name="pub_date" value="1988-01-04" /></li> 
    285 <li>Writer: <select name="writer"> 
     282<li>Headline <input type="text" name="headline" value="New headline" maxlength="50" /></li> 
     283<li>Slug <input type="text" name="slug" value="new-headline" maxlength="50" /></li> 
     284<li>Pub date <input type="text" name="pub_date" value="1988-01-04" /></li> 
     285<li>Writer <select name="writer"> 
    286286<option value="">---------</option> 
    287287<option value="1" selected="selected">Mike Royko</option> 
    288288<option value="2">Bob Woodward</option> 
    289289</select></li> 
    290 <li>Article: <textarea rows="10" cols="40" name="article">Hello.</textarea></li> 
    291 <li>Status: <select name="status"> 
     290<li>Article <textarea rows="10" cols="40" name="article">Hello.</textarea></li> 
     291<li>Status <select name="status"> 
    292292<option value="" selected="selected">---------</option> 
    293293<option value="1">Draft</option> 
    294294<option value="2">Pending</option> 
    295295<option value="3">Live</option> 
    296296</select></li> 
    297 <li>Categories: <select multiple="multiple" name="categories"> 
     297<li>Categories <select multiple="multiple" name="categories"> 
    298298<option value="1" selected="selected">Entertainment</option> 
    299299<option value="2">It&#39;s a test</option> 
    300300<option value="3">Third test</option> 
     
    387387>>> ArticleForm = form_for_model(Article) 
    388388>>> f = ArticleForm(auto_id=False) 
    389389>>> print f.as_ul() 
    390 <li>Headline: <input type="text" name="headline" maxlength="50" /></li> 
    391 <li>Slug: <input type="text" name="slug" maxlength="50" /></li> 
    392 <li>Pub date: <input type="text" name="pub_date" /></li> 
    393 <li>Writer: <select name="writer"> 
     390<li>Headline <input type="text" name="headline" maxlength="50" /></li> 
     391<li>Slug <input type="text" name="slug" maxlength="50" /></li> 
     392<li>Pub date <input type="text" name="pub_date" /></li> 
     393<li>Writer <select name="writer"> 
    394394<option value="" selected="selected">---------</option> 
    395395<option value="1">Mike Royko</option> 
    396396<option value="2">Bob Woodward</option> 
    397397</select></li> 
    398 <li>Article: <textarea rows="10" cols="40" name="article"></textarea></li> 
    399 <li>Status: <select name="status"> 
     398<li>Article <textarea rows="10" cols="40" name="article"></textarea></li> 
     399<li>Status <select name="status"> 
    400400<option value="" selected="selected">---------</option> 
    401401<option value="1">Draft</option> 
    402402<option value="2">Pending</option> 
    403403<option value="3">Live</option> 
    404404</select></li> 
    405 <li>Categories: <select multiple="multiple" name="categories"> 
     405<li>Categories <select multiple="multiple" name="categories"> 
    406406<option value="1">Entertainment</option> 
    407407<option value="2">It&#39;s a test</option> 
    408408<option value="3">Third</option> 
     
    412412>>> Writer.objects.create(name='Carl Bernstein') 
    413413<Writer: Carl Bernstein> 
    414414>>> print f.as_ul() 
    415 <li>Headline: <input type="text" name="headline" maxlength="50" /></li> 
    416 <li>Slug: <input type="text" name="slug" maxlength="50" /></li> 
    417 <li>Pub date: <input type="text" name="pub_date" /></li> 
    418 <li>Writer: <select name="writer"> 
     415<li>Headline <input type="text" name="headline" maxlength="50" /></li> 
     416<li>Slug <input type="text" name="slug" maxlength="50" /></li> 
     417<li>Pub date <input type="text" name="pub_date" /></li> 
     418<li>Writer <select name="writer"> 
    419419<option value="" selected="selected">---------</option> 
    420420<option value="1">Mike Royko</option> 
    421421<option value="2">Bob Woodward</option> 
    422422<option value="3">Carl Bernstein</option> 
    423423</select></li> 
    424 <li>Article: <textarea rows="10" cols="40" name="article"></textarea></li> 
    425 <li>Status: <select name="status"> 
     424<li>Article <textarea rows="10" cols="40" name="article"></textarea></li> 
     425<li>Status <select name="status"> 
    426426<option value="" selected="selected">---------</option> 
    427427<option value="1">Draft</option> 
    428428<option value="2">Pending</option> 
    429429<option value="3">Live</option> 
    430430</select></li> 
    431 <li>Categories: <select multiple="multiple" name="categories"> 
     431<li>Categories <select multiple="multiple" name="categories"> 
    432432<option value="1">Entertainment</option> 
    433433<option value="2">It&#39;s a test</option> 
    434434<option value="3">Third</option> 
  • tests/regressiontests/forms/tests.py

    old new  
    347347...     somechoice = ChoiceField(choices=chain((('', '-'*9),), [(thing['id'], thing['name']) for thing in things])) 
    348348>>> f = SomeForm() 
    349349>>> f.as_table() 
    350 u'<tr><th><label for="id_somechoice">Somechoice:</label></th><td><select name="somechoice" id="id_somechoice">\n<option value="" selected="selected">---------</option>\n<option value="1">And Boom</option>\n<option value="2">One More Thing!</option>\n</select></td></tr>' 
     350u'<tr><th><label for="id_somechoice">Somechoice</label></th><td><select name="somechoice" id="id_somechoice">\n<option value="" selected="selected">---------</option>\n<option value="1">And Boom</option>\n<option value="2">One More Thing!</option>\n</select></td></tr>' 
    351351>>> f.as_table() 
    352 u'<tr><th><label for="id_somechoice">Somechoice:</label></th><td><select name="somechoice" id="id_somechoice">\n<option value="" selected="selected">---------</option>\n<option value="1">And Boom</option>\n<option value="2">One More Thing!</option>\n</select></td></tr>' 
     352u'<tr><th><label for="id_somechoice">Somechoice</label></th><td><select name="somechoice" id="id_somechoice">\n<option value="" selected="selected">---------</option>\n<option value="1">And Boom</option>\n<option value="2">One More Thing!</option>\n</select></td></tr>' 
    353353>>> f = SomeForm({'somechoice': 2}) 
    354354>>> f.as_table() 
    355 u'<tr><th><label for="id_somechoice">Somechoice:</label></th><td><select name="somechoice" id="id_somechoice">\n<option value="">---------</option>\n<option value="1">And Boom</option>\n<option value="2" selected="selected">One More Thing!</option>\n</select></td></tr>' 
     355u'<tr><th><label for="id_somechoice">Somechoice</label></th><td><select name="somechoice" id="id_somechoice">\n<option value="">---------</option>\n<option value="1">And Boom</option>\n<option value="2" selected="selected">One More Thing!</option>\n</select></td></tr>' 
    356356 
    357357You can also pass 'choices' to the constructor: 
    358358>>> w = Select(choices=[(1, 1), (2, 2), (3, 3)]) 
     
    20482048Last name Lennon 
    20492049Birthday 1940-10-9 
    20502050>>> print p 
    2051 <tr><th><label for="id_first_name">First name:</label></th><td><input type="text" name="first_name" value="John" id="id_first_name" /></td></tr> 
    2052 <tr><th><label for="id_last_name">Last name:</label></th><td><input type="text" name="last_name" value="Lennon" id="id_last_name" /></td></tr> 
    2053 <tr><th><label for="id_birthday">Birthday:</label></th><td><input type="text" name="birthday" value="1940-10-9" id="id_birthday" /></td></tr> 
     2051<tr><th><label for="id_first_name">First name</label></th><td><input type="text" name="first_name" value="John" id="id_first_name" /></td></tr> 
     2052<tr><th><label for="id_last_name">Last name</label></th><td><input type="text" name="last_name" value="Lennon" id="id_last_name" /></td></tr> 
     2053<tr><th><label for="id_birthday">Birthday</label></th><td><input type="text" name="birthday" value="1940-10-9" id="id_birthday" /></td></tr> 
    20542054 
    20552055Empty dictionaries are valid, too. 
    20562056>>> p = Person({}) 
     
    20652065... 
    20662066AttributeError: 'Person' object has no attribute 'cleaned_data' 
    20672067>>> print p 
    2068 <tr><th><label for="id_first_name">First name:</label></th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="first_name" id="id_first_name" /></td></tr> 
    2069 <tr><th><label for="id_last_name">Last name:</label></th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="last_name" id="id_last_name" /></td></tr> 
    2070 <tr><th><label for="id_birthday">Birthday:</label></th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="birthday" id="id_birthday" /></td></tr> 
     2068<tr><th><label for="id_first_name">First name</label></th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="first_name" id="id_first_name" /></td></tr> 
     2069<tr><th><label for="id_last_name">Last name</label></th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="last_name" id="id_last_name" /></td></tr> 
     2070<tr><th><label for="id_birthday">Birthday</label></th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="birthday" id="id_birthday" /></td></tr> 
    20712071>>> print p.as_table() 
    2072 <tr><th><label for="id_first_name">First name:</label></th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="first_name" id="id_first_name" /></td></tr> 
    2073 <tr><th><label for="id_last_name">Last name:</label></th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="last_name" id="id_last_name" /></td></tr> 
    2074 <tr><th><label for="id_birthday">Birthday:</label></th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="birthday" id="id_birthday" /></td></tr> 
     2072<tr><th><label for="id_first_name">First name</label></th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="first_name" id="id_first_name" /></td></tr> 
     2073<tr><th><label for="id_last_name">Last name</label></th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="last_name" id="id_last_name" /></td></tr> 
     2074<tr><th><label for="id_birthday">Birthday</label></th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="birthday" id="id_birthday" /></td></tr> 
    20752075>>> print p.as_ul() 
    2076 <li><ul class="errorlist"><li>This field is required.</li></ul><label for="id_first_name">First name:</label> <input type="text" name="first_name" id="id_first_name" /></li> 
    2077 <li><ul class="errorlist"><li>This field is required.</li></ul><label for="id_last_name">Last name:</label> <input type="text" name="last_name" id="id_last_name" /></li> 
    2078 <li><ul class="errorlist"><li>This field is required.</li></ul><label for="id_birthday">Birthday:</label> <input type="text" name="birthday" id="id_birthday" /></li> 
     2076<li><ul class="errorlist"><li>This field is required.</li></ul><label for="id_first_name">First name</label> <input type="text" name="first_name" id="id_first_name" /></li> 
     2077<li><ul class="errorlist"><li>This field is required.</li></ul><label for="id_last_name">Last name</label> <input type="text" name="last_name" id="id_last_name" /></li> 
     2078<li><ul class="errorlist"><li>This field is required.</li></ul><label for="id_birthday">Birthday</label> <input type="text" name="birthday" id="id_birthday" /></li> 
    20792079>>> print p.as_p() 
    20802080<ul class="errorlist"><li>This field is required.</li></ul> 
    2081 <p><label for="id_first_name">First name:</label> <input type="text" name="first_name" id="id_first_name" /></p> 
     2081<p><label for="id_first_name">First name</label> <input type="text" name="first_name" id="id_first_name" /></p> 
    20822082<ul class="errorlist"><li>This field is required.</li></ul> 
    2083 <p><label for="id_last_name">Last name:</label> <input type="text" name="last_name" id="id_last_name" /></p> 
     2083<p><label for="id_last_name">Last name</label> <input type="text" name="last_name" id="id_last_name" /></p> 
    20842084<ul class="errorlist"><li>This field is required.</li></ul> 
    2085 <p><label for="id_birthday">Birthday:</label> <input type="text" name="birthday" id="id_birthday" /></p> 
     2085<p><label for="id_birthday">Birthday</label> <input type="text" name="birthday" id="id_birthday" /></p> 
    20862086 
    20872087If you don't pass any values to the Form's __init__(), or if you pass None, 
    20882088the Form will be considered unbound and won't do any validation. Form.errors 
     
    20992099... 
    21002100AttributeError: 'Person' object has no attribute 'cleaned_data' 
    21012101>>> print p 
    2102 <tr><th><label for="id_first_name">First name:</label></th><td><input type="text" name="first_name" id="id_first_name" /></td></tr> 
    2103 <tr><th><label for="id_last_name">Last name:</label></th><td><input type="text" name="last_name" id="id_last_name" /></td></tr> 
    2104 <tr><th><label for="id_birthday">Birthday:</label></th><td><input type="text" name="birthday" id="id_birthday" /></td></tr> 
     2102<tr><th><label for="id_first_name">First name</label></th><td><input type="text" name="first_name" id="id_first_name" /></td></tr> 
     2103<tr><th><label for="id_last_name">Last name</label></th><td><input type="text" name="last_name" id="id_last_name" /></td></tr> 
     2104<tr><th><label for="id_birthday">Birthday</label></th><td><input type="text" name="birthday" id="id_birthday" /></td></tr> 
    21052105>>> print p.as_table() 
    2106 <tr><th><label for="id_first_name">First name:</label></th><td><input type="text" name="first_name" id="id_first_name" /></td></tr> 
    2107 <tr><th><label for="id_last_name">Last name:</label></th><td><input type="text" name="last_name" id="id_last_name" /></td></tr> 
    2108 <tr><th><label for="id_birthday">Birthday:</label></th><td><input type="text" name="birthday" id="id_birthday" /></td></tr> 
     2106<tr><th><label for="id_first_name">First name</label></th><td><input type="text" name="first_name" id="id_first_name" /></td></tr> 
     2107<tr><th><label for="id_last_name">Last name</label></th><td><input type="text" name="last_name" id="id_last_name" /></td></tr> 
     2108<tr><th><label for="id_birthday">Birthday</label></th><td><input type="text" name="birthday" id="id_birthday" /></td></tr> 
    21092109>>> print p.as_ul() 
    2110 <li><label for="id_first_name">First name:</label> <input type="text" name="first_name" id="id_first_name" /></li> 
    2111 <li><label for="id_last_name">Last name:</label> <input type="text" name="last_name" id="id_last_name" /></li> 
    2112 <li><label for="id_birthday">Birthday:</label> <input type="text" name="birthday" id="id_birthday" /></li> 
     2110<li><label for="id_first_name">First name</label> <input type="text" name="first_name" id="id_first_name" /></li> 
     2111<li><label for="id_last_name">Last name</label> <input type="text" name="last_name" id="id_last_name" /></li> 
     2112<li><label for="id_birthday">Birthday</label> <input type="text" name="birthday" id="id_birthday" /></li> 
    21132113>>> print p.as_p() 
    2114 <p><label for="id_first_name">First name:</label> <input type="text" name="first_name" id="id_first_name" /></p> 
    2115 <p><label for="id_last_name">Last name:</label> <input type="text" name="last_name" id="id_last_name" /></p> 
    2116 <p><label for="id_birthday">Birthday:</label> <input type="text" name="birthday" id="id_birthday" /></p> 
     2114<p><label for="id_first_name">First name</label> <input type="text" name="first_name" id="id_first_name" /></p> 
     2115<p><label for="id_last_name">Last name</label> <input type="text" name="last_name" id="id_last_name" /></p> 
     2116<p><label for="id_birthday">Birthday</label> <input type="text" name="birthday" id="id_birthday" /></p> 
    21172117 
    21182118Unicode values are handled properly. 
    21192119>>> p = Person({'first_name': u'John', 'last_name': u'\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111', 'birthday': '1940-10-9'}) 
    21202120>>> p.as_table() 
    2121 u'<tr><th><label for="id_first_name">First name:</label></th><td><input type="text" name="first_name" value="John" id="id_first_name" /></td></tr>\n<tr><th><label for="id_last_name">Last name:</label></th><td><input type="text" name="last_name" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" id="id_last_name" /></td></tr>\n<tr><th><label for="id_birthday">Birthday:</label></th><td><input type="text" name="birthday" value="1940-10-9" id="id_birthday" /></td></tr>' 
     2121u'<tr><th><label for="id_first_name">First name</label></th><td><input type="text" name="first_name" value="John" id="id_first_name" /></td></tr>\n<tr><th><label for="id_last_name">Last name</label></th><td><input type="text" name="last_name" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" id="id_last_name" /></td></tr>\n<tr><th><label for="id_birthday">Birthday</label></th><td><input type="text" name="birthday" value="1940-10-9" id="id_birthday" /></td></tr>' 
    21222122>>> p.as_ul() 
    2123 u'<li><label for="id_first_name">First name:</label> <input type="text" name="first_name" value="John" id="id_first_name" /></li>\n<li><label for="id_last_name">Last name:</label> <input type="text" name="last_name" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" id="id_last_name" /></li>\n<li><label for="id_birthday">Birthday:</label> <input type="text" name="birthday" value="1940-10-9" id="id_birthday" /></li>' 
     2123u'<li><label for="id_first_name">First name</label> <input type="text" name="first_name" value="John" id="id_first_name" /></li>\n<li><label for="id_last_name">Last name</label> <input type="text" name="last_name" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" id="id_last_name" /></li>\n<li><label for="id_birthday">Birthday</label> <input type="text" name="birthday" value="1940-10-9" id="id_birthday" /></li>' 
    21242124>>> p.as_p() 
    2125 u'<p><label for="id_first_name">First name:</label> <input type="text" name="first_name" value="John" id="id_first_name" /></p>\n<p><label for="id_last_name">Last name:</label> <input type="text" name="last_name" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" id="id_last_name" /></p>\n<p><label for="id_birthday">Birthday:</label> <input type="text" name="birthday" value="1940-10-9" id="id_birthday" /></p>' 
     2125u'<p><label for="id_first_name">First name</label> <input type="text" name="first_name" value="John" id="id_first_name" /></p>\n<p><label for="id_last_name">Last name</label> <input type="text" name="last_name" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" id="id_last_name" /></p>\n<p><label for="id_birthday">Birthday</label> <input type="text" name="birthday" value="1940-10-9" id="id_birthday" /></p>' 
    21262126 
    21272127>>> p = Person({'last_name': u'Lennon'}) 
    21282128>>> p.errors 
     
    22002200the human-readable labels for a field. 
    22012201>>> p = Person(auto_id='%s_id') 
    22022202>>> print p.as_table() 
    2203 <tr><th><label for="first_name_id">First name:</label></th><td><input type="text" name="first_name" id="first_name_id" /></td></tr> 
    2204 <tr><th><label for="last_name_id">Last name:</label></th><td><input type="text" name="last_name" id="last_name_id" /></td></tr> 
    2205 <tr><th><label for="birthday_id">Birthday:</label></th><td><input type="text" name="birthday" id="birthday_id" /></td></tr> 
     2203<tr><th><label for="first_name_id">First name</label></th><td><input type="text" name="first_name" id="first_name_id" /></td></tr> 
     2204<tr><th><label for="last_name_id">Last name</label></th><td><input type="text" name="last_name" id="last_name_id" /></td></tr> 
     2205<tr><th><label for="birthday_id">Birthday</label></th><td><input type="text" name="birthday" id="birthday_id" /></td></tr> 
    22062206>>> print p.as_ul() 
    2207 <li><label for="first_name_id">First name:</label> <input type="text" name="first_name" id="first_name_id" /></li> 
    2208 <li><label for="last_name_id">Last name:</label> <input type="text" name="last_name" id="last_name_id" /></li> 
    2209 <li><label for="birthday_id">Birthday:</label> <input type="text" name="birthday" id="birthday_id" /></li> 
     2207<li><label for="first_name_id">First name</label> <input type="text" name="first_name" id="first_name_id" /></li> 
     2208<li><label for="last_name_id">Last name</label> <input type="text" name="last_name" id="last_name_id" /></li> 
     2209<li><label for="birthday_id">Birthday</label> <input type="text" name="birthday" id="birthday_id" /></li> 
    22102210>>> print p.as_p() 
    2211 <p><label for="first_name_id">First name:</label> <input type="text" name="first_name" id="first_name_id" /></p> 
    2212 <p><label for="last_name_id">Last name:</label> <input type="text" name="last_name" id="last_name_id" /></p> 
    2213 <p><label for="birthday_id">Birthday:</label> <input type="text" name="birthday" id="birthday_id" /></p> 
     2211<p><label for="first_name_id">First name</label> <input type="text" name="first_name" id="first_name_id" /></p> 
     2212<p><label for="last_name_id">Last name</label> <input type="text" name="last_name" id="last_name_id" /></p> 
     2213<p><label for="birthday_id">Birthday</label> <input type="text" name="birthday" id="birthday_id" /></p> 
    22142214 
    22152215If auto_id is any True value whose str() does not contain '%s', the "id" 
    22162216attribute will be the name of the field. 
    22172217>>> p = Person(auto_id=True) 
    22182218>>> print p.as_ul() 
    2219 <li><label for="first_name">First name:</label> <input type="text" name="first_name" id="first_name" /></li> 
    2220 <li><label for="last_name">Last name:</label> <input type="text" name="last_name" id="last_name" /></li> 
    2221 <li><label for="birthday">Birthday:</label> <input type="text" name="birthday" id="birthday" /></li> 
     2219<li><label for="first_name">First name</label> <input type="text" name="first_name" id="first_name" /></li> 
     2220<li><label for="last_name">Last name</label> <input type="text" name="last_name" id="last_name" /></li> 
     2221<li><label for="birthday">Birthday</label> <input type="text" name="birthday" id="birthday" /></li> 
    22222222 
    22232223If auto_id is any False value, an "id" attribute won't be output unless it 
    22242224was manually entered. 
    22252225>>> p = Person(auto_id=False) 
    22262226>>> print p.as_ul() 
    2227 <li>First name: <input type="text" name="first_name" /></li> 
    2228 <li>Last name: <input type="text" name="last_name" /></li> 
    2229 <li>Birthday: <input type="text" name="birthday" /></li> 
     2227<li>First name <input type="text" name="first_name" /></li> 
     2228<li>Last name <input type="text" name="last_name" /></li> 
     2229<li>Birthday <input type="text" name="birthday" /></li> 
    22302230 
    22312231In this example, auto_id is False, but the "id" attribute for the "first_name" 
    22322232field is given. Also note that field gets a <label>, while the others don't. 
     
    22362236...     birthday = DateField() 
    22372237>>> p = PersonNew(auto_id=False) 
    22382238>>> print p.as_ul() 
    2239 <li><label for="first_name_id">First name:</label> <input type="text" id="first_name_id" name="first_name" /></li> 
    2240 <li>Last name: <input type="text" name="last_name" /></li> 
    2241 <li>Birthday: <input type="text" name="birthday" /></li> 
     2239<li><label for="first_name_id">First name</label> <input type="text" id="first_name_id" name="first_name" /></li> 
     2240<li>Last name <input type="text" name="last_name" /></li> 
     2241<li>Birthday <input type="text" name="birthday" /></li> 
    22422242 
    22432243If the "id" attribute is specified in the Form and auto_id is True, the "id" 
    22442244attribute in the Form gets precedence. 
    22452245>>> p = PersonNew(auto_id=True) 
    22462246>>> print p.as_ul() 
    2247 <li><label for="first_name_id">First name:</label> <input type="text" id="first_name_id" name="first_name" /></li> 
    2248 <li><label for="last_name">Last name:</label> <input type="text" name="last_name" id="last_name" /></li> 
    2249 <li><label for="birthday">Birthday:</label> <input type="text" name="birthday" id="birthday" /></li> 
     2247<li><label for="first_name_id">First name</label> <input type="text" id="first_name_id" name="first_name" /></li> 
     2248<li><label for="last_name">Last name</label> <input type="text" name="last_name" id="last_name" /></li> 
     2249<li><label for="birthday">Birthday</label> <input type="text" name="birthday" id="birthday" /></li> 
    22502250 
    22512251>>> class SignupForm(Form): 
    22522252...     email = EmailField() 
     
    23942394<li><label><input type="radio" name="language" value="J" /> Java</label></li> 
    23952395</ul> 
    23962396>>> print f 
    2397 <tr><th>Name:</th><td><input type="text" name="name" /></td></tr> 
    2398 <tr><th>Language:</th><td><ul> 
     2397<tr><th>Name</th><td><input type="text" name="name" /></td></tr> 
     2398<tr><th>Language</th><td><ul> 
    23992399<li><label><input type="radio" name="language" value="P" /> Python</label></li> 
    24002400<li><label><input type="radio" name="language" value="J" /> Java</label></li> 
    24012401</ul></td></tr> 
    24022402>>> print f.as_ul() 
    2403 <li>Name: <input type="text" name="name" /></li> 
    2404 <li>Language: <ul> 
     2403<li>Name <input type="text" name="name" /></li> 
     2404<li>Language <ul> 
    24052405<li><label><input type="radio" name="language" value="P" /> Python</label></li> 
    24062406<li><label><input type="radio" name="language" value="J" /> Java</label></li> 
    24072407</ul></li> 
     
    24202420either as_table() or as_ul(), the label for the RadioSelect will point to the 
    24212421ID of the *first* radio button. 
    24222422>>> print f 
    2423 <tr><th><label for="id_name">Name:</label></th><td><input type="text" name="name" id="id_name" /></td></tr> 
    2424 <tr><th><label for="id_language_0">Language:</label></th><td><ul> 
     2423<tr><th><label for="id_name">Name</label></th><td><input type="text" name="name" id="id_name" /></td></tr> 
     2424<tr><th><label for="id_language_0">Language</label></th><td><ul> 
    24252425<li><label><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li> 
    24262426<li><label><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li> 
    24272427</ul></td></tr> 
    24282428>>> print f.as_ul() 
    2429 <li><label for="id_name">Name:</label> <input type="text" name="name" id="id_name" /></li> 
    2430 <li><label for="id_language_0">Language:</label> <ul> 
     2429<li><label for="id_name">Name</label> <input type="text" name="name" id="id_name" /></li> 
     2430<li><label for="id_language_0">Language</label> <ul> 
    24312431<li><label><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li> 
    24322432<li><label><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li> 
    24332433</ul></li> 
    24342434>>> print f.as_p() 
    2435 <p><label for="id_name">Name:</label> <input type="text" name="name" id="id_name" /></p> 
    2436 <p><label for="id_language_0">Language:</label> <ul> 
     2435<p><label for="id_name">Name</label> <input type="text" name="name" id="id_name" /></p> 
     2436<p><label for="id_language_0">Language</label> <ul> 
    24372437<li><label><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li> 
    24382438<li><label><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li> 
    24392439</ul></p> 
     
    25312531...     composers = MultipleChoiceField(choices=[('J', 'John Lennon'), ('P', 'Paul McCartney')], widget=MultipleHiddenInput) 
    25322532>>> f = SongFormHidden(MultiValueDict(dict(name=['Yesterday'], composers=['J', 'P'])), auto_id=False) 
    25332533>>> print f.as_ul() 
    2534 <li>Name: <input type="text" name="name" value="Yesterday" /><input type="hidden" name="composers" value="J" /> 
     2534<li>Name <input type="text" name="name" value="Yesterday" /><input type="hidden" name="composers" value="J" /> 
    25352535<input type="hidden" name="composers" value="P" /></li> 
    25362536 
    25372537When using CheckboxSelectMultiple, the framework expects a list of input and 
     
    25582558 
    25592559>>> f = EscapingForm({'special_name': "Nothing to escape"}, auto_id=False) 
    25602560>>> print f 
    2561 <tr><th>Special name:</th><td><ul class="errorlist"><li>Something&#39;s wrong with &#39;Nothing to escape&#39;</li></ul><input type="text" name="special_name" value="Nothing to escape" /></td></tr> 
     2561<tr><th>Special name</th><td><ul class="errorlist"><li>Something&#39;s wrong with &#39;Nothing to escape&#39;</li></ul><input type="text" name="special_name" value="Nothing to escape" /></td></tr> 
    25622562>>> f = EscapingForm({'special_name': "Should escape < & > and <script>alert('xss')</script>"}, auto_id=False) 
    25632563>>> print f 
    2564 <tr><th>Special name:</th><td><ul class="errorlist"><li>Something&#39;s wrong with &#39;Should escape &lt; &amp; &gt; and &lt;script&gt;alert(&#39;xss&#39;)&lt;/script&gt;&#39;</li></ul><input type="text" name="special_name" value="Should escape &lt; &amp; &gt; and &lt;script&gt;alert(&#39;xss&#39;)&lt;/script&gt;" /></td></tr> 
     2564<tr><th>Special name</th><td><ul class="errorlist"><li>Something&#39;s wrong with &#39;Should escape &lt; &amp; &gt; and &lt;script&gt;alert(&#39;xss&#39;)&lt;/script&gt;&#39;</li></ul><input type="text" name="special_name" value="Should escape &lt; &amp; &gt; and &lt;script&gt;alert(&#39;xss&#39;)&lt;/script&gt;" /></td></tr> 
    25652565 
    25662566# Validating multiple fields in relation to another ########################### 
    25672567 
     
    26152615{} 
    26162616>>> f = UserRegistration({}, auto_id=False) 
    26172617>>> print f.as_table() 
    2618 <tr><th>Username:</th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="username" maxlength="10" /></td></tr> 
    2619 <tr><th>Password1:</th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="password" name="password1" /></td></tr> 
    2620 <tr><th>Password2:</th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="password" name="password2" /></td></tr> 
     2618<tr><th>Username</th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="username" maxlength="10" /></td></tr> 
     2619<tr><th>Password1</th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="password" name="password1" /></td></tr> 
     2620<tr><th>Password2</th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="password" name="password2" /></td></tr> 
    26212621>>> f.errors 
    26222622{'username': [u'This field is required.'], 'password1': [u'This field is required.'], 'password2': [u'This field is required.']} 
    26232623>>> f = UserRegistration({'username': 'adrian', 'password1': 'foo', 'password2': 'bar'}, auto_id=False) 
     
    26252625{'__all__': [u'Please make sure your passwords match.']} 
    26262626>>> print f.as_table() 
    26272627<tr><td colspan="2"><ul class="errorlist"><li>Please make sure your passwords match.</li></ul></td></tr> 
    2628 <tr><th>Username:</th><td><input type="text" name="username" value="adrian" maxlength="10" /></td></tr> 
    2629 <tr><th>Password1:</th><td><input type="password" name="password1" value="foo" /></td></tr> 
    2630 <tr><th>Password2:</th><td><input type="password" name="password2" value="bar" /></td></tr> 
     2628<tr><th>Username</th><td><input type="text" name="username" value="adrian" maxlength="10" /></td></tr> 
     2629<tr><th>Password1</th><td><input type="password" name="password1" value="foo" /></td></tr> 
     2630<tr><th>Password2</th><td><input type="password" name="password2" value="bar" /></td></tr> 
    26312631>>> print f.as_ul() 
    26322632<li><ul class="errorlist"><li>Please make sure your passwords match.</li></ul></li> 
    2633 <li>Username: <input type="text" name="username" value="adrian" maxlength="10" /></li> 
    2634 <li>Password1: <input type="password" name="password1" value="foo" /></li> 
    2635 <li>Password2: <input type="password" name="password2" value="bar" /></li> 
     2633<li>Username <input type="text" name="username" value="adrian" maxlength="10" /></li> 
     2634<li>Password1 <input type="password" name="password1" value="foo" /></li> 
     2635<li>Password2 <input type="password" name="password2" value="bar" /></li> 
    26362636>>> f = UserRegistration({'username': 'adrian', 'password1': 'foo', 'password2': 'foo'}, auto_id=False) 
    26372637>>> f.errors 
    26382638{} 
     
    26522652...         self.fields['birthday'] = DateField() 
    26532653>>> p = Person(auto_id=False) 
    26542654>>> print p 
    2655 <tr><th>First name:</th><td><input type="text" name="first_name" /></td></tr> 
    2656 <tr><th>Last name:</th><td><input type="text" name="last_name" /></td></tr> 
    2657 <tr><th>Birthday:</th><td><input type="text" name="birthday" /></td></tr> 
     2655<tr><th>First name</th><td><input type="text" name="first_name" /></td></tr> 
     2656<tr><th>Last name</th><td><input type="text" name="last_name" /></td></tr> 
     2657<tr><th>Birthday</th><td><input type="text" name="birthday" /></td></tr> 
    26582658 
    26592659Instances of a dynamic Form do not persist fields from one Form instance to 
    26602660the next. 
     
    26662666>>> field_list = [('field1', CharField()), ('field2', CharField())] 
    26672667>>> my_form = MyForm(field_list=field_list) 
    26682668>>> print my_form 
    2669 <tr><th>Field1:</th><td><input type="text" name="field1" /></td></tr> 
    2670 <tr><th>Field2:</th><td><input type="text" name="field2" /></td></tr> 
     2669<tr><th>Field1</th><td><input type="text" name="field1" /></td></tr> 
     2670<tr><th>Field2</th><td><input type="text" name="field2" /></td></tr> 
    26712671>>> field_list = [('field3', CharField()), ('field4', CharField())] 
    26722672>>> my_form = MyForm(field_list=field_list) 
    26732673>>> print my_form 
    2674 <tr><th>Field3:</th><td><input type="text" name="field3" /></td></tr> 
    2675 <tr><th>Field4:</th><td><input type="text" name="field4" /></td></tr> 
     2674<tr><th>Field3</th><td><input type="text" name="field3" /></td></tr> 
     2675<tr><th>Field4</th><td><input type="text" name="field4" /></td></tr> 
    26762676 
    26772677>>> class MyForm(Form): 
    26782678...     default_field_1 = CharField() 
     
    26842684>>> field_list = [('field1', CharField()), ('field2', CharField())] 
    26852685>>> my_form = MyForm(field_list=field_list) 
    26862686>>> print my_form 
    2687 <tr><th>Default field 1:</th><td><input type="text" name="default_field_1" /></td></tr> 
    2688 <tr><th>Default field 2:</th><td><input type="text" name="default_field_2" /></td></tr> 
    2689 <tr><th>Field1:</th><td><input type="text" name="field1" /></td></tr> 
    2690 <tr><th>Field2:</th><td><input type="text" name="field2" /></td></tr> 
     2687<tr><th>Default field 1</th><td><input type="text" name="default_field_1" /></td></tr> 
     2688<tr><th>Default field 2</th><td><input type="text" name="default_field_2" /></td></tr> 
     2689<tr><th>Field1</th><td><input type="text" name="field1" /></td></tr> 
     2690<tr><th>Field2</th><td><input type="text" name="field2" /></td></tr> 
    26912691>>> field_list = [('field3', CharField()), ('field4', CharField())] 
    26922692>>> my_form = MyForm(field_list=field_list) 
    26932693>>> print my_form 
    2694 <tr><th>Default field 1:</th><td><input type="text" name="default_field_1" /></td></tr> 
    2695 <tr><th>Default field 2:</th><td><input type="text" name="default_field_2" /></td></tr> 
    2696 <tr><th>Field3:</th><td><input type="text" name="field3" /></td></tr> 
    2697 <tr><th>Field4:</th><td><input type="text" name="field4" /></td></tr> 
     2694<tr><th>Default field 1</th><td><input type="text" name="default_field_1" /></td></tr> 
     2695<tr><th>Default field 2</th><td><input type="text" name="default_field_2" /></td></tr> 
     2696<tr><th>Field3</th><td><input type="text" name="field3" /></td></tr> 
     2697<tr><th>Field4</th><td><input type="text" name="field4" /></td></tr> 
    26982698 
    26992699Similarly, changes to field attributes do not persist from one Form instance 
    27002700to the next. 
     
    27522752...     birthday = DateField() 
    27532753>>> p = Person(auto_id=False) 
    27542754>>> print p 
    2755 <tr><th>First name:</th><td><input type="text" name="first_name" /></td></tr> 
    2756 <tr><th>Last name:</th><td><input type="text" name="last_name" /></td></tr> 
    2757 <tr><th>Birthday:</th><td><input type="text" name="birthday" /><input type="hidden" name="hidden_text" /></td></tr> 
     2755<tr><th>First name</th><td><input type="text" name="first_name" /></td></tr> 
     2756<tr><th>Last name</th><td><input type="text" name="last_name" /></td></tr> 
     2757<tr><th>Birthday</th><td><input type="text" name="birthday" /><input type="hidden" name="hidden_text" /></td></tr> 
    27582758>>> print p.as_ul() 
    2759 <li>First name: <input type="text" name="first_name" /></li> 
    2760 <li>Last name: <input type="text" name="last_name" /></li> 
    2761 <li>Birthday: <input type="text" name="birthday" /><input type="hidden" name="hidden_text" /></li> 
     2759<li>First name <input type="text" name="first_name" /></li> 
     2760<li>Last name <input type="text" name="last_name" /></li> 
     2761<li>Birthday <input type="text" name="birthday" /><input type="hidden" name="hidden_text" /></li> 
    27622762>>> print p.as_p() 
    2763 <p>First name: <input type="text" name="first_name" /></p> 
    2764 <p>Last name: <input type="text" name="last_name" /></p> 
    2765 <p>Birthday: <input type="text" name="birthday" /><input type="hidden" name="hidden_text" /></p> 
     2763<p>First name <input type="text" name="first_name" /></p> 
     2764<p>Last name <input type="text" name="last_name" /></p> 
     2765<p>Birthday <input type="text" name="birthday" /><input type="hidden" name="hidden_text" /></p> 
    27662766 
    27672767With auto_id set, a HiddenInput still gets an ID, but it doesn't get a label. 
    27682768>>> p = Person(auto_id='id_%s') 
    27692769>>> print p 
    2770 <tr><th><label for="id_first_name">First name:</label></th><td><input type="text" name="first_name" id="id_first_name" /></td></tr> 
    2771 <tr><th><label for="id_last_name">Last name:</label></th><td><input type="text" name="last_name" id="id_last_name" /></td></tr> 
    2772 <tr><th><label for="id_birthday">Birthday:</label></th><td><input type="text" name="birthday" id="id_birthday" /><input type="hidden" name="hidden_text" id="id_hidden_text" /></td></tr> 
     2770<tr><th><label for="id_first_name">First name</label></th><td><input type="text" name="first_name" id="id_first_name" /></td></tr> 
     2771<tr><th><label for="id_last_name">Last name</label></th><td><input type="text" name="last_name" id="id_last_name" /></td></tr> 
     2772<tr><th><label for="id_birthday">Birthday</label></th><td><input type="text" name="birthday" id="id_birthday" /><input type="hidden" name="hidden_text" id="id_hidden_text" /></td></tr> 
    27732773>>> print p.as_ul() 
    2774 <li><label for="id_first_name">First name:</label> <input type="text" name="first_name" id="id_first_name" /></li> 
    2775 <li><label for="id_last_name">Last name:</label> <input type="text" name="last_name" id="id_last_name" /></li> 
    2776 <li><label for="id_birthday">Birthday:</label> <input type="text" name="birthday" id="id_birthday" /><input type="hidden" name="hidden_text" id="id_hidden_text" /></li> 
     2774<li><label for="id_first_name">First name</label> <input type="text" name="first_name" id="id_first_name" /></li> 
     2775<li><label for="id_last_name">Last name</label> <input type="text" name="last_name" id="id_last_name" /></li> 
     2776<li><label for="id_birthday">Birthday</label> <input type="text" name="birthday" id="id_birthday" /><input type="hidden" name="hidden_text" id="id_hidden_text" /></li> 
    27772777>>> print p.as_p() 
    2778 <p><label for="id_first_name">First name:</label> <input type="text" name="first_name" id="id_first_name" /></p> 
    2779 <p><label for="id_last_name">Last name:</label> <input type="text" name="last_name" id="id_last_name" /></p> 
    2780 <p><label for="id_birthday">Birthday:</label> <input type="text" name="birthday" id="id_birthday" /><input type="hidden" name="hidden_text" id="id_hidden_text" /></p> 
     2778<p><label for="id_first_name">First name</label> <input type="text" name="first_name" id="id_first_name" /></p> 
     2779<p><label for="id_last_name">Last name</label> <input type="text" name="last_name" id="id_last_name" /></p> 
     2780<p><label for="id_birthday">Birthday</label> <input type="text" name="birthday" id="id_birthday" /><input type="hidden" name="hidden_text" id="id_hidden_text" /></p> 
    27812781 
    27822782If a field with a HiddenInput has errors, the as_table() and as_ul() output 
    27832783will include the error message(s) with the text "(Hidden field [fieldname]) " 
     
    27862786>>> p = Person({'first_name': 'John', 'last_name': 'Lennon', 'birthday': '1940-10-9'}, auto_id=False) 
    27872787>>> print p 
    27882788<tr><td colspan="2"><ul class="errorlist"><li>(Hidden field hidden_text) This field is required.</li></ul></td></tr> 
    2789 <tr><th>First name:</th><td><input type="text" name="first_name" value="John" /></td></tr> 
    2790 <tr><th>Last name:</th><td><input type="text" name="last_name" value="Lennon" /></td></tr> 
    2791 <tr><th>Birthday:</th><td><input type="text" name="birthday" value="1940-10-9" /><input type="hidden" name="hidden_text" /></td></tr> 
     2789<tr><th>First name</th><td><input type="text" name="first_name" value="John" /></td></tr> 
     2790<tr><th>Last name</th><td><input type="text" name="last_name" value="Lennon" /></td></tr> 
     2791<tr><th>Birthday</th><td><input type="text" name="birthday" value="1940-10-9" /><input type="hidden" name="hidden_text" /></td></tr> 
    279227