aboutsummaryrefslogtreecommitdiff
path: root/tagging/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'tagging/models.py')
-rw-r--r--tagging/models.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/tagging/models.py b/tagging/models.py
index d43f22d..860cf81 100644
--- a/tagging/models.py
+++ b/tagging/models.py
@@ -162,8 +162,18 @@ class TagManager(models.Manager):
Passing a value for ``min_count`` implies ``counts=True``.
"""
- 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: