QuerySet .dates() method should span relationships
|Reported by:||coleifer||Owned by:||Valentin Golev|
|Component:||Database layer (models, ORM)||Version:||1.2|
|Cc:||ego@…||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
In the current implementation, QuerySet.dates() cannot span relationships. This limits the date-based generic views to only working if the date_field is on the same model as your queryset. The actual object lookup for the date-based generic views *works* - it is when the generic view tries to build the date_list that it fails.
# here's a silly example of what I'm talking about >>> from django.contrib.auth.models import Group, User >>> User.objects.dates('last_login', 'year') [datetime.datetime(2009, 1, 1, 0, 0), datetime.datetime(2010, 1, 1, 0, 0)] >>> Group.objects.dates('user__last_login', 'year') FieldDoesNotExist: Group has no field named 'user__last_login'
The error is raised by this call:
I suspect this could be tweaked by changing something around here:
Change History (10)
comment:1 Changed 6 years ago by
|Owner:||changed from nobody to Valentin Golev|
|Status:||new → assigned|
|Triage Stage:||Unreviewed → Accepted|