Fewer queries on poll view

This commit is contained in:
Aurélien Delobelle 2017-04-09 17:37:15 +02:00
parent ce70269e7b
commit 8870b5ace2

View file

@ -94,7 +94,10 @@ def logout(request):
@login_required
def survey(request, survey_id):
survey = get_object_or_404(Survey, id=survey_id)
survey = get_object_or_404(
Survey.objects.prefetch_related('questions', 'questions__answers'),
id=survey_id,
)
if not survey.survey_open or survey.old:
raise Http404
success = False