title: Displaying Sum of Objects from Django Model into Template
body: <p>I am using Django 1.8.3 and Python 3.4.3</p>
  
  <p>I have a model which returns a list of objects to my template with a 'for' loop; one of the tables is for 'sales'. I would like to create a tag that is the Sum of off all 'sales' and insert the total_sales into my template with a tag.  The premise is to keep from having to manually add all the columns together to get the total and just have a section on the page that automatically calculates and displays the total.</p>
  
  <p>Below is my current model/view.  Any help is greatly appreciated.  Thank you.</p>
  
  <p>model.py</p>
  
  <pre><code>class Traffic(models.Model):
      date = models.DateField()
      traffic = models.PositiveIntegerField(null=True)
      day_of_week = models.CharField(max_length=255, null=True)
      ifs_signups = models.IntegerField(null=True)
      campaigns = models.IntegerField(null=True)
      sales = models.PositiveIntegerField(null=True)
  
      def month(self):
          return self.date.strftime("%B")
  
      def quarter(self):
          item = self.date.strftime("%B")
          q1 = (["January", "February", "March"])
          q2 = (["April", "May", "June"])
          q3 = (["July", "August", "September"])
          q4 = (["October", "November", "December"])
  
          if item in q1:
              return "1st Quarter"
          elif item in q2:
              return "2nd Quarter"
          elif item in q3:
              return "3rd Quarter"
          elif item in q4:
              return "4th Quarter"
          else:
              return "No Date Specified"
  
      def conversions(self):
          conversion = self.sales / self.traffic
          return "%r" % conversion
  </code></pre>
  
  <p>views.py (the def _total_sales(self): below i my attempt)</p>
  
  <pre><code>from django.db.models import Sum
  
  from .models import Traffic, Email
  
  
  class TrafficListView(ListView):
      model = Traffic
      template_name = 'dashboard/pages/traffic.html'
  
      def get_context_data(self, **kwargs):
          context = super(TrafficListView, self).get_context_data(**kwargs)
          return context
  
      def _total_sales(self):
          return self.objects.aggregate(total_sales=Sum('sales'))
  </code></pre>