X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/f1ec080b394326e35074c57e682789176cd3f244..842aeda3f5811649639b281c30c52b87306bae67:/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: