Ticket #13987: 13987_fix_2_with_tests.diff
File 13987_fix_2_with_tests.diff, 2.2 KB (added by , 14 years ago) |
---|
-
django/db/models/options.py
113 113 # Promote the first parent link in lieu of adding yet another 114 114 # field. 115 115 field = self.parents.value_for_index(0) 116 already_created = [fld for fld in self.local_fields if fld.name == field.name] 117 if already_created: 118 field = already_created[0] 116 119 field.primary_key = True 117 120 self.setup_pk(field) 118 121 else: -
tests/regressiontests/model_inheritance_regress/models.py
137 137 class MessyBachelorParty(BachelorParty): 138 138 pass 139 139 140 # Check concrete -> abstract -> concrete inheritance 141 class SearchableLocation(models.Model): 142 keywords = models.CharField(max_length=256) 143 144 class Station(SearchableLocation): 145 name = models.CharField(max_length=128) 146 147 class Meta: 148 abstract = True 149 150 class BusStation(Station): 151 bus_routes = models.CommaSeparatedIntegerField(max_length=128) 152 inbound = models.BooleanField() 153 154 class TrainStation(Station): 155 zone = models.IntegerField() 156 140 157 __test__ = {'API_TESTS':""" 141 158 # Regression for #7350, #7202 142 159 # Check that when you create a Parent object with a specific reference to an … … 386 403 >>> p4.bachelorparty_set.all() 387 404 [<BachelorParty: Bachelor party for Bob>, <BachelorParty: Bachelor party for Dave>] 388 405 406 # Regression for #13987 407 # Check that a primary key is defined for models that inherit from an abstract 408 # model, which in turn inherits from a concrete model. 409 >>> len([field for field in BusStation._meta.local_fields if field.primary_key]) 410 1 411 >>> len([field for field in TrainStation._meta.local_fields if field.primary_key]) 412 1 413 >>> BusStation._meta.pk.model is BusStation 414 True 415 >>> TrainStation._meta.pk.model is TrainStation 416 True 417 389 418 """} 390 419