Ticket #3652: 6213-choicefield-test-only.patch
File 6213-choicefield-test-only.patch, 1.4 KB (added by , 17 years ago) |
---|
-
tests/modeltests/model_forms/models.py
70 70 def __unicode__(self): 71 71 return self.phone 72 72 73 class Todo(models.Model): 74 what = models.CharField(maxlength=100) 75 importance = models.IntegerField(choices=((1, 'Extremely important'), (2,'Floss cat first')), blank=True, null=True) 76 73 77 __test__ = {'API_TESTS': """ 74 78 >>> from django.newforms import form_for_model, form_for_instance, save_instance, BaseForm, Form, CharField 75 79 >>> import datetime … … 560 564 True 561 565 >>> f.cleaned_data 562 566 {'phone': u'312-555-1212', 'description': u'Assistance'} 567 568 # ChoiceField ############################################################ 569 570 >>> ChoiceForm = form_for_model(Todo) 571 >>> f = ChoiceForm() 572 >>> print f.as_ul() 573 <li><label for="id_what">What:</label> <input id="id_what" type="text" name="what" maxlength="100" /></li> 574 <li><label for="id_importance">Importance:</label> <select name="importance" id="id_importance"> 575 <option value="" selected="selected">---------</option> 576 <option value="1">Extremely important</option> 577 <option value="2">Floss cat first</option> 578 </select></li> 579 >>> f = ChoiceForm({'what': 'floss cat', 'importance': ''}) 580 >>> f.is_valid() 581 True 582 >>> f.save() 583 <Todo: Todo object> 563 584 """}