Johnf
On 12/10/2014 03:23 PM, Ruslan Batukaev wrote:
--Suppose I have the following SQL query:
SELECT a.id, ct, 1 as oneFROM article aLEFT JOIN (SELECT article_id, count(distinct(tag)) AS ctFROM article_tagWHERE tag IN ('football', 'tennis', 'django', 'mma')GROUP BY article_idORDER BY ct) t ON t.article_id = a.IDORDER BY t.ct DESC NULLS LAST, (a.blog = 'ign.com') DESC NULLS LAST, rating DESC NULLS LAST;
Now execute it in Django:
Article.objects.raw(query);
According to [Django documentation][1], the queryset will contain the values of `ct` and `one` for each article. However, while it prints the value of `one` correctly, it does not for `ct` and just returns `null`. Is there any way to get `ct` for each article?Thanks.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5a93348a-6d18-4735-988e-5cbadc6ca245%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment