X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/67df302167539474edd02b57c2e8bd30349d7625..ce9b29777e9dc6d8d285a18d5aa8f75905b0a229:/apps/newtagging/models.py diff --git a/apps/newtagging/models.py b/apps/newtagging/models.py index ea2a41f8e..e9b114145 100644 --- a/apps/newtagging/models.py +++ b/apps/newtagging/models.py @@ -215,8 +215,18 @@ class TagManager(models.Manager): if parse_lookup: raise AttributeError("'TagManager.usage_for_queryset' is not compatible with pre-queryset-refactor versions of Django.") - extra_joins = ' '.join(queryset.query.get_from_clause()[0][1:]) - where, params = queryset.query.where.as_sql() + if getattr(queryset.query, 'get_compiler', None): + # Django 1.2+ + compiler = queryset.query.get_compiler(using='default') + extra_joins = ' '.join(compiler.get_from_clause()[0][1:]) + where, params = queryset.query.where.as_sql( + compiler.quote_name_unless_alias, compiler.connection + ) + else: + # Django pre-1.2 + extra_joins = ' '.join(queryset.query.get_from_clause()[0][1:]) + where, params = queryset.query.where.as_sql() + if where: extra_criteria = 'AND %s' % where else: