X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/ea8925059c81175c3a432a006779764d65308ad8..510a4d0c1e4496bee580f8a1dff2f3674fdb727c:/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: