title: Django: sum values in for loop
body: <p>i want to sum of the orders price in formset.
  how to sum <code>int(food.price) * int(f.order_count)</code> ?</p>
  
  <pre><code>def reservation_f(request, year, month, day):
      # order_count = Food.objects.filter(serve_date__startswith = datetime.date(int(year), int(month), int(day))).count()
      ReservationFormset = modelformset_factory(
          Reservation,
          extra = 1,
          fields = ('order_count', 'order_name', 'order_date'),
          form = Reserve,
          )
      if request.method == "POST":
          formset = ReservationFormset(request.POST, queryset=Food.objects.none(),
          form_kwargs={'month': month, 'year': year, 'day':day})
          if formset.is_valid():
              formset = formset.save(commit=False)
              for f in formset:
                  food = Food.objects.get(
                      serve_date__startswith = datetime.date(int(year), int(month), int(day)),
                      food_name=f.order_name)
                  print int(food.price) * int(f.order_count)
              for f in formset:
                  f.user = request.user
                  f.save()
  
          return HttpResponse("Add")
      else:
          formset = ReservationFormset(queryset=Food.objects.none(),
          form_kwargs={'month': month, 'year': year, 'day':day})
          return render(request, 'form.html', {'formset':formset})
  </code></pre>