Allow an annotation to match a field name when using .values on a query set.
Ticket http://code.djangoproject.com/ticket/11256 has the unfortunate effect of stopping a values query from working.
class Author(models.Model):
last_updated = models.DateField()
class Book(models.Model):
author = models.ForeignKey(Author, related_name='books')
pubdate = models.DateField()
authors = Author.objects.values("id").annotate(last_updated=Max('books__pubdate'))
In this case we are using values to only use that one field and last_updated is no longer overriding anything.
Change History
(6)
Component: |
Uncategorized → ORM aggregation
|
milestone: |
→ 1.3
|
Owner: |
nobody removed
|
Triage Stage: |
Unreviewed → Accepted
|
Keywords: |
blocker regression added
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
Component: |
ORM aggregation → Database layer (models, ORM)
|
This is a regression in trunk, so it needs to be on the 1.3 milestone.