Ticket #10808: model_inheritance.py.diff
File model_inheritance.py.diff, 1.2 KB (added by , 15 years ago) |
---|
-
models.py
116 116 def __unicode__(self): 117 117 return u"%s the parking lot" % self.name 118 118 119 # 120 # Diamond inheritance test 121 # 122 class FoodPlace(models.Model): 123 name = models.CharField(max_length=255) 124 125 class Bar(FoodPlace): 126 pass 127 128 class Pizzeria(FoodPlace): 129 pass 130 131 class PizzeriaBar(Bar, Pizzeria): 132 pizza_bar_specific_field = models.CharField(max_length = 255) 133 119 134 __test__ = {'API_TESTS':""" 120 135 # The Student and Worker models both have 'name' and 'age' fields on them and 121 136 # inherit the __unicode__() method, just as with normal Python subclassing. … … 310 325 3 311 326 >>> settings.DEBUG = False 312 327 328 # Test of diamond inheritance __init__. If B and C inherit from A, and D inherits from B and C, we should be able to use __init__ for D to properly set all the fields, regardless of the redundant copies of A's fields that D inherits from B and C. 329 330 >>> p = PizzeriaBar(name="Mike's", pizza_bar_specific_field="Doodle") 331 >>> p.name == "Mike's" 332 True 333 >>> p.pizza_bar_specific_field == "Doodle" 334 True 313 335 """}