diff -r 1a5661fe179d tests/modeltests/model_inheritance/models.py
a
|
b
|
|
119 | 119 | def __unicode__(self): |
120 | 120 | return u"%s the parking lot" % self.name |
121 | 121 | |
| 122 | class AbstractModelOne(models.Model): |
| 123 | field_one = models.BooleanField() |
| 124 | |
| 125 | class Meta: |
| 126 | abstract = True |
| 127 | |
| 128 | class AbstractModelTwo(models.Model): |
| 129 | field_two = models.BooleanField() |
| 130 | |
| 131 | class Meta: |
| 132 | abstract = True |
| 133 | |
| 134 | class OneTwo(AbstractModelOne, AbstractModelTwo): |
| 135 | pass |
| 136 | |
| 137 | class TwoOne(AbstractModelTwo, AbstractModelOne): |
| 138 | pass |
| 139 | |
122 | 140 | # |
123 | 141 | # Abstract base classes with related models where the sub-class has the |
124 | 142 | # same name in a different app and inherits from the same abstract base |
diff -r 1a5661fe179d tests/modeltests/model_inheritance/tests.py
a
|
b
|
|
4 | 4 | from django.test import TestCase |
5 | 5 | |
6 | 6 | from models import (Chef, CommonInfo, ItalianRestaurant, ParkingLot, Place, |
7 | | Post, Restaurant, Student, StudentWorker, Supplier, Worker) |
| 7 | Post, Restaurant, Student, StudentWorker, Supplier, Worker, OneTwo, TwoOne) |
8 | 8 | |
9 | 9 | |
10 | 10 | class ModelInheritanceTests(TestCase): |
… |
… |
|
269 | 269 | self.assertNumQueries(1, |
270 | 270 | lambda: ItalianRestaurant.objects.select_related("chef")[0].chef |
271 | 271 | ) |
| 272 | |
| 273 | names = [field.name for field in OneTwo._meta.fields] |
| 274 | self.assertEqual(["id", "field_one", "field_two"], names) |
| 275 | |
| 276 | names = [field.name for field in TwoOne._meta.fields] |
| 277 | self.assertEqual(["id", "field_two", "field_one"], names) |
| 278 | |