#24485: Support for annotate(end=F('start') + F('duration'),
output_field=DateTimeField)
----------------------------------------------+---------------------------
     Reporter:  yoyoma                        |      Owner:  nobody
         Type:  New feature                   |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  master
     Severity:  Normal                        |   Keywords:  durationfield
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+---------------------------
 I've modeled a {{{Ticket}}} as such:

 {{{
 class Ticket(models.Model):
     # ... other fields omitted
     active_at = models.DateTimeField()
     duration = models.DurationField()
 }}}

 Using {{{duration}}} this way is more valuable than simply defining an
 {{{expires_at}}} {{{DateTimeField}}}, because it has the same amount of
 information and also allows me to do things like
 {{{Ticket.objects.filter(duration__gt=timedelta(days=1))}}}. However, I
 ran into a problem when I tried to run the following:

 {{{
 Ticket.objects.annotate(
     expires_at=models.Sum(
         models.F('active_at') + models.F('duration'),
         output_field=models.DateTimeField()
     )
 )
 }}}

 The exception occurs during datetime parsing when a {{{float}}} is
 encountered during an attempted regexp search. Does this imply that all
 {{{Sum}}} results will be of the type {{{float}}}? If so, does that
 disqualify supporting the above example as a possible feature?

--
Ticket URL: <https://code.djangoproject.com/ticket/24485>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.84ad39183a08e104b557e5aef9def424%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to