Ticket #5505: tests-regressiontests-forms-models.patch
File tests-regressiontests-forms-models.patch, 1.0 KB (added by , 17 years ago) |
---|
-
tests/regressiontests/forms/models.py
2 2 3 3 class BoundaryModel(models.Model): 4 4 positive_integer = models.PositiveIntegerField(null=True, blank=True) 5 5 6 class ForeignKeyModel(models.Model): 7 foreign_key = models.ForeignKey('self', null=True, blank=True) 8 6 9 __test__ = {'API_TESTS': """ 7 10 >>> from django.newforms import form_for_model 8 11 … … 18 21 >>> f.is_valid() 19 22 False 20 23 24 >>> from django.newforms import form_for_instance 25 >>> fk1 = ForeignKeyModel() 26 >>> fk1.save() 27 >>> fk2 = ForeignKeyModel(foreign_key=fk1) 28 >>> fk2.save() 29 >>> fk2.foreign_key == fk1 30 True 31 >>> Form = form_for_instance(fk1, fields=[], formfield_callback=lambda f, initial: 'do nothing') 32 >>> f = Form() 33 >>> f.is_valid() 34 False 35 >>> f = Form({'foreign_key':fk1}) 36 >>> f.is_valid() 37 True 38 >>> f.errors 39 {} 40 21 41 """}