What will be the replacement for .extra()?

194 views
Skip to first unread message

Luis Masuelli

unread,
Dec 9, 2015, 6:10:49 PM12/9/15
to Django users
When I see the docs (https://docs.djangoproject.com/en/1.8/ref/models/querysets/#extra), I notice .extra will be deprecated and removed. Is there a plan for the replacement? As I see it, limiting ourselves to using Manager.raw() is not a good idea, since you cannot work anymore on a RawQueryset object (as you can work on any Queryset object you called .extra). So my question is: Is there a good replacement for .extra being planned?


Russell Keith-Magee

unread,
Dec 9, 2015, 8:07:28 PM12/9/15
to Django Users
Hi Luis,

On Thu, Dec 10, 2015 at 7:10 AM, Luis Masuelli <luisfm...@gmail.com> wrote:
When I see the docs (https://docs.djangoproject.com/en/1.8/ref/models/querysets/#extra), I notice .extra will be deprecated and removed. Is there a plan for the replacement? As I see it, limiting ourselves to using Manager.raw() is not a good idea, since you cannot work anymore on a RawQueryset object (as you can work on any Queryset object you called .extra). So my question is: Is there a good replacement for .extra being planned?

Yes - the Query Expression API.


Yours,
Russ Magee %-)

thinkwell

unread,
Dec 10, 2015, 4:22:39 PM12/10/15
to Django users
So how would an query like this be written, with the new Query Expression API? Where a count of events by day is required but the date column is datetime?

Triggers.objects.all().extra({"day": "date_trunc('day', date)"}).values_list('name', 'severity', 'day').annotate(total=Count('severity'))

Dan Stephenson

unread,
Dec 10, 2015, 6:35:23 PM12/10/15
to Django users
Reply all
Reply to author
Forward
0 new messages