Hi,

currently I am moving my django project towards Django 1.2. During
that step I want to replace code like that

    query_set = query_set.extra(select = {
        'image_count': '''SELECT COUNT(*) FROM  image
                                          WHERE topic.id =
image.topic_id
                                          AND   topic.trashed_at =
image.trashed_at''',
        'video_count': '''SELECT COUNT(*) FROM  video
                                          WHERE topic.id =
video.topic_id
                                          AND   topic.trashed_at =
video.trashed_at''',
    })

Selecting a topic instance or a list of topic instances I also want to
know the amount of images associated with the topic, which share the
same value for trashed_at.

Can this be written using the annotate method and the Count class?

Best regards,
Oliver

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to