Skip to content
Browse files

Added monthly tallies. Fixed template name

  • Loading branch information...
1 parent 16d392c commit 8d6e217f3f6aee6895091e39355dec4f99d07b02 David Cramer committed Nov 13, 2009
Showing with 6 additions and 5 deletions.
  1. +2 −2 django_histograms/templates/histograms/report.html
  2. +4 −3 django_histograms/utils.py
View
4 django_histograms/templates/histograms/report.html
@@ -4,9 +4,9 @@
</style>
{% endif %}
<p>During this time period there were {{ total }} entries.</p>
-{% for month, data in results %}
+{% for month, data, count in results %}
<div class="histogram">
- <h2 style="padding-top: 1em;">{{ month|date:"F Y" }}</h2>
+ <h2 style="padding-top: 1em;">{{ month|date:"F Y" }} ({{ count }})</h2>
<ul>
{% for num in data %}
<li>
View
7 django_histograms/utils.py
@@ -69,7 +69,7 @@ def render(self, css=False):
context = self.get_report()
if css:
context['css'] = HISTOGRAM_CSS
- return render_to_string("histogram/report.html", context)
+ return render_to_string("histograms/report.html", context)
def get_query_set(self):
return self._queryset or self.model.objects.all()
@@ -85,8 +85,8 @@ def get_report(self):
).filter(**{"%s__gt" % self.attname: last_month})
months = [
- (this_month, [0] * calendar.monthrange(this_month.year, this_month.month)[1]),
- (last_month, [0] * calendar.monthrange(last_month.year, last_month.month)[1]),
+ [this_month, ([0] * calendar.monthrange(this_month.year, this_month.month)[1]), 0],
+ [last_month, ([0] * calendar.monthrange(last_month.year, last_month.month)[1]), 0],
]
for data in qs.iterator():
@@ -99,6 +99,7 @@ def get_report(self):
else:
continue
months[idx][1][data[self.attname].day-1] += data["num"]
+ months[idx][2] += data["num"]
return {
"results": months,

0 comments on commit 8d6e217

Please sign in to comment.
Something went wrong with that request. Please try again.