Ticket #7778: tests_queries.diff

File tests_queries.diff, 1.2 KB (added by James Murty, 16 years ago)
  • tests/regressiontests/queries/models.py

     
    189189class Related(models.Model):
    190190    custom = models.ForeignKey(CustomPk)
    191191
     192# An inter-related setup with a model subclass that has a nullable
     193# path to another model, and a return path from that model.
    192194
     195class Celebrity(models.Model):
     196    name = models.CharField("Name", max_length=20)
     197    greatest_fan = models.ForeignKey("Fan", null=True, unique=True)
     198
     199class TvChef(Celebrity):
     200    pass
     201   
     202class Fan(models.Model):
     203    fan_of = models.ForeignKey(Celebrity)
     204
     205
    193206__test__ = {'API_TESTS':"""
    194207>>> t1 = Tag.objects.create(name='t1')
    195208>>> t2 = Tag.objects.create(name='t2', parent=t1)
     
    830843...     obj.save()
    831844...     if i > 10: break
    832845
     846Bug #7778 - Model subclasses cannot be deleted if a nullable foreign key relates
     847to a model that relates back.
     848
     849>>> tvc = TvChef.objects.create(name="Huey")
     850>>> f1 = Fan.objects.create(fan_of=tvc)
     851>>> f2 = Fan.objects.create(fan_of=tvc)
     852>>> tvc.delete()
    833853"""}
    834854
Back to Top