Using extra field in Django Annotate

1

I'm trying to add a column named today in a Model with .extra() , to work on an annotate . I'm not finding. He is not finding the field.

duration = ExpressionWrapper(F('today') - F('pub_date'), output_field=fields.DurationField()) 
list_posts = posts.extra(select={'today': "now()"}).annotate(duration=duration)

Error

Cannot resolve keyword 'today' into field.

Note It does not get to display in the list of possible fields today or anything like that.

    
asked by anonymous 14.09.2017 / 17:24

0 answers