Added test for ForeignObject.get_extra_descriptor_filter()

This commit is contained in:
Alex Hill 2015-08-03 19:44:13 +10:00 committed by Tim Graham
parent 14c1fd0730
commit b47e862d3a
2 changed files with 4 additions and 1 deletions

View File

@ -146,7 +146,7 @@ class ActiveTranslationField(models.ForeignObject):
def get_extra_restriction(self, where_class, alias, related_alias):
return ColConstraint(alias, 'lang', get_language())
def get_extra_descriptor_filter(self):
def get_extra_descriptor_filter(self, instance):
return {'lang': get_language()}
def contribute_to_class(self, cls, name):

View File

@ -319,6 +319,9 @@ class MultiColumnFKTests(TestCase):
at1_fi.save()
at2_en = ArticleTranslation(article=a1, lang='en', title='Title', body='Lalalalala')
at2_en.save()
self.assertEqual(Article.objects.get(pk=a1.pk).active_translation, at1_fi)
with self.assertNumQueries(1):
fetched = Article.objects.select_related('active_translation').get(
active_translation__title='Otsikko')