That's fine as am using Postgres on centos 7

Cheers
Steve 

Sent from my iPhone

> On 19 Jan 2016, at 21:19, Simon Charette <[email protected]> wrote:
> 
> Hi Steve,
> 
> It looks like it might only work on PostgreSQL unti this bug is fixed.
> 
> Simon
> 
> Le mardi 19 janvier 2016 14:59:57 UTC-5, Steven Nash a écrit :
>> 
>> Hi Simon,
>> 
>> Thanks, I'll give that ago.
>> 
>> Cheers,
>> 
>> Steve
>> 
>>> On Tuesday, 19 January 2016 18:52:06 UTC, Simon Charette wrote:
>>> Hi Steve,
>>> 
>>> You can use annotate for this.
>>> 
>>> from datetime import timedelta
>>> 
>>> from django.db.models import DurationField, ExpressionWrapper, F
>>> 
>>> Entry.objects.annotate(
>>>     duration=ExpressionWrapper(
>>>         F('end') - F('start'), output_field=DurationField()
>>>     )
>>> ).filter(duration__gte=timedelta(minutes=time_in_minutes)
>>> 
>>> 
>>> Cheers,
>>> Simon
>>> 
>>> Le mardi 19 janvier 2016 13:01:36 UTC-5, Steven Nash a écrit :
>>>> 
>>>> Hi,
>>>> 
>>>> Given an object such as:
>>>> 
>>>> class Entry(models.Model):
>>>>   start = models.TimeField()
>>>>   end = models.TimeField()
>>>> 
>>>> I'd like to be able to say something like:
>>>> 
>>>> Entry.objects.filter(F('end')-F('start')__gt=time_in_minutes)
>>>> 
>>>> Is there a way of doing this without implementing a separate duration 
>>>> field and having a setter for start and end update it?
>>>> 
>>>> Cheers,
>>>> Steve
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Django users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/django-users/xIP7hhp0WqQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/3bd1db8e-0b53-4b3b-b781-51e4cc8a687c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1E3B4129-5341-4968-990C-3C2E8E8225A6%40bitsolver.co.uk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to