0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-30 01:46:24 +01:00

Optimise (and fix ordering of) submission queries

This commit is contained in:
Matt Westcott 2016-09-01 15:59:12 +01:00
parent f2b4e4758a
commit 0e052f3db8
2 changed files with 6 additions and 4 deletions

View File

@ -13,13 +13,15 @@ class BaseFormSubmissionsPanel(EditHandler):
def render(self):
from .models import FormSubmission
submissions = FormSubmission.objects.filter(page=self.instance)
submission_count = submissions.count()
if not submissions:
if not submission_count:
return ''
return mark_safe(render_to_string(self.template, {
'self': self,
'submissions': submissions
'submission_count': submission_count,
'last_submit_time': submissions.order_by('submit_time').last().submit_time,
}))

View File

@ -9,7 +9,7 @@
<label class="label">{{ total }}</label>
<div class="field-content">
<div class="input">
<a href="{% url 'wagtailforms:list_submissions' self.instance.id %}">{{ submissions.count }}</a>
<a href="{% url 'wagtailforms:list_submissions' self.instance.id %}">{{ submission_count }}</a>
</div>
</div>
</div>
@ -19,7 +19,7 @@
<label class="label">{{ latest }}</label>
<div class="field-content">
<p>
{{ submissions.last.submit_time }}
{{ last_submit_time }}
</p>
</div>
</div>