在图11-1中说:https://djangobook.com/managing-users-admin/我想在“选择要更改的用户”下添加一些静态文本。
我尝试过这个(https://docs.djangoproject.com/en/dev/ref/contrib/admin/#other-methods),这似乎是正确的答案
和
我遵循了这个示例customizing django admin ChangeForm template / adding custom content
但是对我都不起作用...以下是我的代码段:
admin.py:
HighscoreAdmin(admin.ModelAdmin)类: change_form_template ='admin / my_app / change_form.html'
def change_view(self, request, object_id, form_url='', extra_context=None):
extra_context = extra_context or {}
extra_context['static_text'] = 'Some static text'
return super(HighscoreAdmin, self).change_view(
request, object_id, form_url, extra_context=extra_context,
)
...
change_form.html:
{% extends "admin/change_form.html" %}
{% block form_top %}
{{ static_text }}
{% endblock %}