我正在扩展change_list.html,我需要输出一个在settings.py中定义的变量。
如何将特定变量传递到自定义管理模板上下文中?
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)