X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/46fdca9049d4b7806bc4d6ec33973a3fc19153c4..7bce2277e95107a35ea6bd47d692bc0f7ea71819:/utils.py?ds=inline diff --git a/utils.py b/utils.py index 5fc3274..340e9e4 100644 --- a/utils.py +++ b/utils.py @@ -40,16 +40,19 @@ class ContentTypeSubclassLimiter(ContentTypeLimiter): def q_object(self): contenttype_pks = [] - for subclass in self.cls.__subclasses__(): - try: - if issubclass(subclass, models.Model): - if not subclass._meta.abstract: - if not self.inclusive and subclass is self.cls: - continue - contenttype = ContentType.objects.get_for_model(subclass) - contenttype_pks.append(contenttype.pk) - except: - pass + def handle_subclasses(cls): + for subclass in cls.__subclasses__(): + try: + if issubclass(subclass, models.Model): + if not subclass._meta.abstract: + if not self.inclusive and subclass is self.cls: + continue + contenttype = ContentType.objects.get_for_model(subclass) + contenttype_pks.append(contenttype.pk) + handle_subclasses(subclass) + except: + pass + handle_subclasses(self.cls) return models.Q(pk__in=contenttype_pks)