#12891: wishlist: allow .dates() query to span relations
------------------------------------------+---------------------------------
 Reporter:  til                           |       Owner:  nobody    
   Status:  new                           |   Milestone:            
Component:  Database layer (models, ORM)  |     Version:  1.2-beta  
 Keywords:                                |       Stage:  Unreviewed
Has_patch:  0                             |  
------------------------------------------+---------------------------------
 At the moment, the dates() query only accepts field parameters that do not
 span relations. It would be nice if support for more complex cases was
 added, so that a query like this would be possible:

 {{{
 queryset.dates('foreignkey__date', 'year')
 }}}

 I currently use the following hack to work around this:

 {{{
     # check if date_field spans relations
     fields = date_field.split('__')
     for field in fields[:-1]:
         relation_field = getattr(queryset.model, field)
         queryset = relation_field.field.rel.to.objects.all()
     dates = queryset.dates(fields[-1], 'year')
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12891>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

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

Reply via email to