I've the following problem: I am making a fulltext-index based search, resulting in a query_set constructed in a somewhat more complex way:
revisions = Revision.objects.select_related().filter(published=True, contentEntry__master__archived=False).extra(select={"relevance":"MATCH (title, cont\ ent) AGAINST (%s)"}, where=("MATCH (title, content) AGAINST (%s)", subquery), params=("certificate", "certificate")).order_by("- relevance") This is packed as a custom Manager function, since the subquery is out of context, if I'm not using select_related. The subquery there is a dependent subquery that takes care to only look in the latest article revision. It all works as a charm, using the resulting set is not a problem. Except when I pass it to a paginator, in which case I get SQL query error: (1054, "Unknown column 'kb_article_contententry.id' in 'where clause'"). As I see it, this is the subquery, failing to execute, since the count probably does not add the necessary joins for it to be valid. The problem comes when the ObjectPaginator tries to select the "hits" property. The current code executes this: if self._hits is None: # Try .count() or fall back to len(). try: self._hits = int(self.query_set.count()) except (AttributeError, TypeError, ValueError): # AttributeError if query_set has no object count. # TypeError if query_set.count() required arguments. # ValueError if int() fails. self._hits = len(self.query_set) return self._hits Which in my situation does not handle the exception and it's being propagated upwards. Is there any good solution to the problem, such that .count() will be able to include the necessary joins for my query to work ? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---