﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20278	Passing self to object query may cause infinite regression	anonymous	nobody	"This commit introduced passing the kwargs to the DoesNotExist Query Exception:

https://github.com/django/django/commit/d5b93d3281fe93cbef5de84a52

This involves a call of the __unicode__() method on the given query objects and may lead to an infinity regression, if the __unicode__ method depends on the same query.

The error occured in my custom translation system:

{{{

class Model:

    (...)

    def defaultTranslation(self):
        """"""
        :return: ModelTranslation
        """"""
        try:
            defaultTranslation = ModelTranslation.objects.get(base=self, language__code=settings.FALLBACK_LANGUAGE)
        except ObjectDoesNotExist:
            raise CustomException('Model {0} does not have a default translation.'.format(str(self.id)))
        return defaultTranslation

    def __unicode__(self):
        try:
            return self.defaultTranslation.name
        except CustomException:
            return self.abbreviation
}}}

Changing the query to reference the id fixes the problem.


{{{
            defaultTranslation = ModelTranslation.objects.get(base_id=self.id, language__code=settings.FALLBACK_LANGUAGE)

}}}
"	Bug	closed	Database layer (models, ORM)	1.5	Release blocker	fixed			Accepted	0	0	0	0	1	0
