我刚刚走过the installation guide for Django CMS而我很遗憾没有看到显示的管理员风格。
这就是我所看到的:
以下是教程中的图片:
http://docs.django-cms.org/en/latest/_images/basic-page-form.png
看来由于某种原因,管理员风格并没有开始。
这是我的settings.py
:
"""
Django settings for projectname project.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# True base path of the entire project, ie directory of setup.py
PROJECT_DIR = os.path.dirname(
os.path.join(os.path.dirname(__file__), '..'))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'things'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
SITE_ID = 1
# Application definition
INSTALLED_APPS = (
# Default
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.sites',
'django.contrib.staticfiles',
# Pipeline
'pipeline',
# Django CMS
'mptt',
'menus',
'sekizai',
'djangocms_admin_style',
'cms'
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
# Django CMS
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware',
)
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.request",
"django.core.context_processors.static",
"django.core.context_processors.tz",
"django.contrib.messages.context_processors.messages",
'sekizai.context_processors.sekizai',
'cms.context_processors.cms_settings',
)
MIGRATION_MODULES = {
'cms': 'cms.migrations_django',
'menus': 'menus.migrations_django',
}
ROOT_URLCONF = 'projectname.urls'
WSGI_APPLICATION = 'projectname.wsgi.application'
# Pipeline
# http://django-pipeline.readthedocs.org
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
PIPELINE_COMPILERS = (
'pipeline.compilers.less.LessCompiler'
)
PIPELINE_CSS = {
}
PIPELINE_JS = {
}
# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/
LANGUAGES = [
('en-us', 'English'),
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
MEDIA_ROOT = os.path.join(PROJECT_DIR, "media")
MEDIA_URL = "/media/"
STATIC_ROOT = os.path.join(PROJECT_DIR, "static")
STATIC_URL = '/static/'
TEMPLATE_DIRS = (
os.path.join(PROJECT_DIR, "templates"),
)
CMS_TEMPLATES = (
('template_1.html', 'Template One'),
)
作为参考,以下是我的网址:
from django.conf import settings
from django.conf.urls import include, url, patterns
from django.conf.urls.i18n import i18n_patterns
from django.conf.urls.static import static
from django.contrib import admin
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^', include('cms.urls')),
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
我错过了什么导致管理员无法获得正确的样式?
答案 0 :(得分:1)
在INSTALLED_APPS
中,您必须将'django.contrib.admin'
置于'djangocms_admin_style'
之下,例如:
...
'djangocms_admin_style',
'django.contrib.admin',
...
'djangocms_admin_style', # for the admin skin. You **must** add 'djangocms_admin_style' in the list **before** 'django.contrib.admin'.
之后,样式可以正确显示。