diff -r 0354c968050b tests/regressiontests/queries/models.py
a
|
b
|
try:
|
16 | 16 | except NameError: |
17 | 17 | from django.utils.itercompat import sorted |
18 | 18 | |
| 19 | class DumbCategory(models.Model): |
| 20 | pass |
| 21 | |
| 22 | class NamedCategory(DumbCategory): |
| 23 | name = models.CharField(max_length=10) |
| 24 | |
19 | 25 | class Tag(models.Model): |
20 | 26 | name = models.CharField(max_length=10) |
21 | 27 | parent = models.ForeignKey('self', blank=True, null=True, |
22 | 28 | related_name='children') |
| 29 | category = models.ForeignKey(NamedCategory, null=True, default=None) |
23 | 30 | |
24 | 31 | class Meta: |
25 | 32 | ordering = ['name'] |
… |
… |
class PointerB(models.Model):
|
240 | 247 | |
241 | 248 | |
242 | 249 | __test__ = {'API_TESTS':""" |
243 | | >>> t1 = Tag.objects.create(name='t1') |
244 | | >>> t2 = Tag.objects.create(name='t2', parent=t1) |
| 250 | >>> generic = NamedCategory.objects.create(name="Generic") |
| 251 | >>> t1 = Tag.objects.create(name='t1', category=generic) |
| 252 | >>> t2 = Tag.objects.create(name='t2', parent=t1, category=generic) |
245 | 253 | >>> t3 = Tag.objects.create(name='t3', parent=t1) |
246 | 254 | >>> t4 = Tag.objects.create(name='t4', parent=t3) |
247 | 255 | >>> t5 = Tag.objects.create(name='t5', parent=t3) |
… |
… |
Bug #6981
|
700 | 708 | >>> Tag.objects.select_related('parent').order_by('name') |
701 | 709 | [<Tag: t1>, <Tag: t2>, <Tag: t3>, <Tag: t4>, <Tag: t5>] |
702 | 710 | |
| 711 | Bug #TBD |
| 712 | >>> Tag.objects.select_related('parent', "category").order_by('name') |
| 713 | [<Tag: t1>, <Tag: t2>, <Tag: t3>, <Tag: t4>, <Tag: t5>] |
| 714 | >>> Tag.objects.select_related('parent', "parent__category").order_by('name') |
| 715 | [<Tag: t1>, <Tag: t2>, <Tag: t3>, <Tag: t4>, <Tag: t5>] |
| 716 | |
703 | 717 | Bug #6180, #6203 -- dates with limits and/or counts |
704 | 718 | >>> Item.objects.count() |
705 | 719 | 4 |