I am trying to use the select keyword in extra. But I cannot properly
quote the the expression for postrgres. I am using the
django.contrib.comments. I started with this snippet
http://www.djangosnippets.org/snippets/1101/ which returns the number
of comments for an object. However, the code does not work. The
problem that the field django_comment.object_pk is text and my item pk
is integer.
In postgres, this works:
select count(*)
from django_comments
where django_comments.content_type_id=12 and
django_comments.object_pk='332';
But using extra(select={'comment_count': sql,}) where
sql = '''select count(*)
from django_comments
where django_comments.content_type_id=12 and
django_comments.object_pk=
%s'''
gives me an error every way that I have tried to add quotes. (This
includes django.db.connection.ops.quote_name.)
Any ideas on how to embedded quotes in postgres?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---