Tuesday, 15 September 2015

Subtract the aggregation of two sums in a view in Django -


I am trying to create a profit area, so taking two aggregations of the image and subtracting them unfortunately, I Can not do this like this? Is there a way to accomplish this? I use the model, but I'm not calling it in template

  def view (requested): result_list = Result.objects.order_by ('- entryID') [: 5] From .db.models the amount of imports win = result.abass.Sell.) Total (totals ('win'), yoga ('entry'))> gt; Gt; Gt; & Gt; & Gt; & Gt; & Gt; & Gt; & Gt; Benefits = winnings.winnings__sum - winnings.entry__sum & lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; & Lt; Template = Loader .get_template ('result.html') Context = RequestContext (Request, {'result_list': result_list, 'winnings': winning, 'profit': profit,}) HttpResponse return (template.render (context)) <    

total returns a dictionary:

< Pre> profit = win ["winnings__sum"] - wins ["entry__sum"]

This is the reason that winnings.winnings__sum works in a template But not in dragon


No comments:

Post a Comment