Re: Filter object by calculating duration from start and end time

2016-01-19 Thread Steven Nash
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 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 écri

Re: Filter object by calculating duration from start and end time

2016-01-19 Thread Simon Charette
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

Re: Filter object by calculating duration from start and end time

2016-01-19 Thread Steven Nash
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

Re: Filter object by calculating duration from start and end time

2016-01-19 Thread Xristos Xristoou
can used this and for the dates fields ? Τη Τρίτη, 19 Ιανουαρίου 2016 - 8:01:36 μ.μ. UTC+2, ο χρήστης Steven Nash έγραψε: > > 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:

Re: Filter object by calculating duration from start and end time

2016-01-19 Thread Simon Charette
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('

Filter object by calculating duration from start and end time

2016-01-19 Thread Steven Nash
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