﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
25403	Subqueries: a common case where people get tempted to use .extra()	Paolo	nobody	"As written in the documentation I submit a use case where the `.extra()` method seems the only way to do what I need. Given this model:
{{{
	from django.db import models
	
	
	class Post(models.Model):
	    text = models.CharField(max_length=255)

	
	class Comment(models.Model):
	    text = models.CharField(max_length=255)
	    needs_attention = models.BooleanField(default=False)
	    created_at = models.DateTimeField(auto_now_add=True)
	    post = models.ForeignKey(Post)
	
}}}
	        
I can `annotate` the list of posts with:

{{{
Post.objects.annotate(last_comment_date=Max('comment__created_at'))
}}}

	
to know the `last_comment_date`, how to annotate to set a value for `last_comment_needs_attention`?

I mean how can I obtain more informations from the comments while listing the `posts`? 

I see that this is a quite common request as a feature of the Django ORM, the most detailed description of this problem can be found in [http://blog.roseman.org.uk/2010/08/14/getting-related-item-aggregate/ this nice blog post] .

Is there any plan to allow such a way to annotate? Thx"	New feature	closed	Database layer (models, ORM)	dev	Normal	duplicate	QuerySet.extra		Unreviewed	0	0	0	0	0	0
