[英]Django Admin Template OverRide Issue
I'm currently using Django 2.0.5 for Pycharm-2018.1.2 I recently started working on my first project which basically requires me to work on the admin part of Django. 我目前在Pycharm-2018.1.2中使用Django 2.0.5,我最近开始从事我的第一个项目,这基本上需要我从事Django的管理部分。 I've managed to get my project working but I'm having issues with overriding the Admin Template for some reason... I've followed a few tutorials and read a few articles on this forum but i still couldn't find out what's going wrong..
我已经设法使我的项目正常工作,但是由于某些原因,我在覆盖管理模板方面遇到了问题。出问题了..
Here's what i have in my 'settings.py' 这就是我的“ settings.py”中的内容
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '-r3^d48%3rh7xrecgl9*3r(had#9nz%7nsn$y%h&o$3_ary*q7'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'Bugs.apps.BugsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'BugReport.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates'), ]
,
'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',
],
},
},
]
WSGI_APPLICATION = 'BugReport.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
I have a directory named templates->admin->base_site.html I have also created a folder called static which contains 3 other directories (css, html,js) 我有一个名为templates-> admin-> base_site.html的目录,我还创建了一个名为static的文件夹,其中包含3个其他目录(css,html,js)
The base_site.html has the following html code base_site.html具有以下html代码
{% extends "admin/base.html" %}
{% block title %}{{ title }} | {{ site_title|default:_('Bug site admin') }}{% endblock %}
{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">{{ site_header|default:_('Bug administration') }}</a></h1>
{% endblock %}
{% block nav-global %}{% endblock %}
Even then, The main admin login page still shows Django Administration 即使如此,主管理员登录页面仍显示Django管理
Where am i going wrong? 我要去哪里错了? How Do i Change the templates?
如何更改模板? Is there another way?
还有另一种方法吗? If you need any more details, do let me know and I'll post it as soon as possible.
如果您需要更多详细信息,请告诉我,我会尽快将其发布。
PS: please do bare in mind that I'm still a beginner and I dont know a lot about the technical aspects yet. PS:请记住我仍然是一个初学者,并且我对技术方面还不了解。
I haven't hosted the website yet. 我尚未托管该网站。
Update I have One App Called Bugs which contains The admin.py 更新我有一个名为Bugs的应用程序,其中包含admin.py
而不是{{ site_header|default:_('Bug administration') }}
而是编写Bug administration
。
In admin.py add 在admin.py中添加
admin.site.site_header="header"
admin.site.site_title="title"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.