Sunday, 15 February 2015

Django annotate with extra field display -


I have a model from which I am trying to comment on the average difference between 2 datetime fields.

<> & gt; & Gt; & Gt; X = MyModel.objects.all ()> & gt; & Gt; & Gt; Additional (select = {'average': average ('date (order_order_directory) - date (order accepted)') ')}) = ('> gt; & gt; Y [['quantity__sum': 1, '' Product__category__category_name ': u'badges', 'product__model_name': u'Non SIDA '}, {quantity__sum}: 6,' product__ category = category_name ': u'business', 'product_model_name': u 'SIDA'}]

But the above question does not display the average value in the list. How can I take this additional area?

You can try doing something like this:

  x.an Notate (sum = sum (sum = sum), average = average ('order__queue__checkin_time', field = 'date__order_date) - date (order__queue__checkin_time)')  

field keyword overrides the fields in the AVG-section. You also have the possibility to override the function using the keyword function .


No comments:

Post a Comment