我正在扩展change_list.html,我需要输出settings.py
中定义的变量如何将该特定变量传递到自定义管理模板上下文?
答案 0 :(得分:68)
class MyModelAdmin(admin.ModelAdmin):
...
def changelist_view(self, request, extra_context=None):
extra_context = extra_context or {}
extra_context['some_var'] = 'This is what I want to show'
return super(MyModelAdmin, self).changelist_view(request, extra_context=extra_context)