Commits

Peter Nixon  committed c36944d

tagging: support for django 1.2

The tagging app really should be upgraded, but that currently breaks other
things, so for the time being, backport
http://code.google.com/p/django-tagging/source/detail?r=172 which is the fix for
http://code.google.com/p/django-tagging/issues/detail?id=233

  • Participants
  • Parent commits 5b6d964

Comments (0)

Files changed (1)

File apps/tagging/managers.py

         greater than or equal to ``min_count`` will be returned.
         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 hasattr(queryset.query, 'get_compiler'):
+            # 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: