Ticket #5505: tests-regressiontests-forms-models.patch

File tests-regressiontests-forms-models.patch, 1.0 KB (added by danlarkin, 17 years ago)
  • tests/regressiontests/forms/models.py

     
    22
    33class BoundaryModel(models.Model):
    44    positive_integer = models.PositiveIntegerField(null=True, blank=True)
    5    
     5
     6class ForeignKeyModel(models.Model):
     7    foreign_key = models.ForeignKey('self', null=True, blank=True)
     8
    69__test__ = {'API_TESTS': """
    710>>> from django.newforms import form_for_model
    811
     
    1821>>> f.is_valid()
    1922False
    2023
     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
     30True
     31>>> Form = form_for_instance(fk1, fields=[], formfield_callback=lambda f, initial: 'do nothing')
     32>>> f = Form()
     33>>> f.is_valid()
     34False
     35>>> f = Form({'foreign_key':fk1})
     36>>> f.is_valid()
     37True
     38>>> f.errors
     39{}
     40
    2141"""}
Back to Top