对于那些想知道将上述 Adam 响应中的覆盖数据放在哪里的人,这取决于您的 TEMPLATES DIRS 在设置文件中的分配位置。例如:
settings.py
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [(os.path.join(BASE_DIR, 'templates')),], # <- Template path to put the html file
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
注意 DIRS 目录。这将转换为与我的 manage.py 文件处于同一级别的模板文件夹。
在该模板文件夹中,我有另一个名为 admin 的文件夹和一个名为 base 的 html 文件。所以它看起来像这样:\projectname\templates\admin\base.html
然后在 base.html 文件中,我有亚当从 documentation theming support 中提到的代码
{% extends 'admin/base.html' %}
{% block extrahead %}{{ block.super }}
<style>
:root {
--primary: #9774d5;
--secondary: #785cab;
--link-fg: #7c449b;
--link-selected-fg: #8f5bb2;
--body-fg: #333;
--body-bg: #fff;
--body-quiet-color: #666;
--body-loud-color: #000;
--darkened-bg: #f8f8f8; /* A bit darker than --body-bg */
--selected-bg: #e4e4e4; /* E.g. selected table cells */
--selected-row: #ffc;
}
</style>
{% endblock %}
这现在应该适合您了。如果您在此处使用这些精确设置,它将是带有紫色的浅色主题。然后你就可以相应地。