diff --git a/questionnaire/admin.py b/questionnaire/admin.py index c6b0ce4..bba3efc 100644 --- a/questionnaire/admin.py +++ b/questionnaire/admin.py @@ -28,10 +28,12 @@ class QuestionAdmin(admin.ModelAdmin): ordering = ['questionset__questionnaire', 'questionset', 'number'] inlines = [ChoiceInline] - def queryset(self, request): - # we have a custom template - qs = Questionnaire.objects.all().order_by('name') - return qs + def changelist_view(self, request, extra_context=None): + "Hack to have Questionnaire list accessible for custom changelist template" + if not extra_context: + extra_context = {} + extra_context['questionnaires'] = Questionnaire.objects.all().order_by('name') + return super(QuestionAdmin, self).changelist_view(request, extra_context) class QuestionnaireAdmin(admin.ModelAdmin): pass diff --git a/questionnaire/templates/admin/questionnaire/question/change_list.html b/questionnaire/templates/admin/questionnaire/question/change_list.html index 7ba4c4b..2b83e0a 100644 --- a/questionnaire/templates/admin/questionnaire/question/change_list.html +++ b/questionnaire/templates/admin/questionnaire/question/change_list.html @@ -16,7 +16,7 @@ function togglehide(id) { return false; } -{% for questionnaire in cl.get_query_set %} +{% for questionnaire in questionnaires %}

{{ questionnaire.name }}