我使用Django CMS制作了一个简单的网站。除了管理工具栏上的样式外,一切似乎都有效。他们没有加载。如何配置应用程序或服务器以正确提供它们?
这是settings.py
进口口
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__ file __)))
#快速启动开发设置 - 不适合生产
#参见https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
#SECURITY警告:保密秘密密钥用于生产秘密!
SECRET_KEY ='这里有些秘密'
#SECURITY警告:在生产中打开调试时不要运行!
DEBUG = True
ALLOWED_HOSTS = []
#应用程序定义
INSTALLED_APPS =(
' djangocms_admin_style&#39 ;,
' django.contrib.admin&#39 ;,
' django.contrib.auth&#39 ;,
' django.contrib.contenttypes&#39 ;,
' django.contrib.sessions&#39 ;,
' django.contrib.messages&#39 ;,
' django.contrib.staticfiles&#39 ;,
' django.contrib.sites&#39 ;,
' CMS&#39 ;,
'菜单&#39 ;,
'树胡&#39 ;,
' sekizai&#39 ;,
'过滤器&#39 ;,
' easy_thumbnails&#39 ;,
' MPTT&#39 ;,
' djangocms_text_ckeditor&#39 ;,
' djangocms_link&#39 ;,
' djangocms_file&#39 ;,
' djangocms_picture&#39 ;,
' djangocms_video&#39 ;,
' djangocms_googlemap&#39 ;,
' djangocms_snippet&#39 ;,
' djangocms_style&#39 ;,
' djangocms_column&#39 ;,
' aldryn_bootstrap3&#39 ;,
' parler&#39 ;,
' aldryn_apphooks_config&#39 ;,
' aldryn_categories&#39 ;,
' aldryn_common&#39 ;,
' aldryn_newsblog&#39 ;,
' aldryn_people&#39 ;,
' aldryn_reversion&#39 ;,
' aldryn_translation_tools&#39 ;,
' sortedm2m&#39 ;,
' taggit&#39 ;,
'反转&#39 ;,
' aldryn_boilerplates&#39 ;,
'绝对&#39 ;,
' aldryn_forms&#39 ;,
' aldryn_forms.contrib.email_notifications&#39 ;,
'验证码&#39 ;,
' emailit&#39 ;,
)
MIDDLEWARE_CLASSES =(
' cms.middleware.utils.ApphookReloadMiddleware&#39 ;,
' django.contrib.sessions.middleware.SessionMiddleware&#39 ;,
' django.middleware.common.CommonMiddleware&#39 ;,
' django.middleware.csrf.CsrfViewMiddleware&#39 ;,
' django.contrib.auth.middleware.AuthenticationMiddleware&#39 ;,
' django.contrib.auth.middleware.SessionAuthenticationMiddleware&#39 ;,
' django.contrib.messages.middleware.MessageMiddleware&#39 ;,
' django.middleware.clickjacking.XFrameOptionsMiddleware&#39 ;,
' django.middleware.security.SecurityMiddleware&#39 ;,
' django.middleware.locale.LocaleMiddleware&#39 ;,
' cms.middleware.user.CurrentUserMiddleware&#39 ;,
' cms.middleware.page.CurrentPageMiddleware&#39 ;,
' cms.middleware.toolbar.ToolbarMiddleware&#39 ;,
' cms.middleware.language.LanguageCookieMiddleware&#39 ;,
)
ROOT_URLCONF =' iboyko.urls'
模板= [
{
' BACKEND':' django.template.backends.django.DjangoTemplates',
' DIRS':[os.path.join(BASE_DIR,' templates')],
' APP_DIRS':是的,
' OPTIONS':{
' context_processors':[
' django.template.context_processors.debug&#39 ;,
' django.template.context_processors.request&#39 ;,
' django.contrib.auth.context_processors.auth&#39 ;,
' django.contrib.messages.context_processors.messages&#39 ;,
' sekizai.context_processors.sekizai&#39 ;,
' cms.context_processors.cms_settings&#39 ;,
]
},
},
]
WSGI_APPLICATION =' app_name.wsgi.application'
#数据库
#https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
'默认':{
' ENGINE':' django.db.backends.sqlite3',
' NAME':os.path.join(BASE_DIR,' db.sqlite3'),
}
}
#国际化
#https://docs.djangoproject.com/en/1.8/topics/i18n/
LANGUAGE_CODE =' en'
TIME_ZONE =' UTC'
USE_I18N =真
USE_L10N =真
USE_TZ =真
#静态文件(CSS,JavaScript,图像)
#https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL =' / static /'
STATICFILES_DIRS = [
os.path.join(BASE_DIR," static"),
]
MEDIA_URL =" / media /"
MEDIA_ROOT = os.path.join(BASE_DIR," media")
SITE_ID = 1
语言= [
(' en','英语'),
(' de'德国'),
]
CMS_TEMPLATES = [
(' base.html','主页模板'),
]
THUMBNAIL_HIGH_RESOLUTION = True
THUMBNAIL_PROCESSORS =(
' easy_thumbnails.processors.colorspace&#39 ;,
' easy_thumbnails.processors.autocrop&#39 ;,
' filer.thumbnail_processors.scale_and_crop_with_subject_location&#39 ;,
' easy_thumbnails.processors.filters'
)
wsgi.conf:
#注意:mod_wsgi不能在同一个apache进程中共存
#mod_wsgi_python3。仅在mod_wsgi_python3不是时才加载
#已经加载。
< IfModule!wsgi_module>
LoadModule wsgi_module modules / mod_wsgi.so
< / IfModule>
#WSGIScriptAlias / test_wsgi /var/www/vhosts/app_name/test_wsgi.py
#WSGIScriptAlias / /var/www/vhosts/app_name/app_name/wsgi.py
WSGIPythonPath / var / www / vhosts / app_name-blog / app_name-blog-env:/ var / www / vhosts / app_name-blog / app_name-blog-env / lib / pyth $
WSGIPythonHome / var / www / vhosts / app_name-blog / app_name-blog-env
< VirtualHost *:80>
#这是基于名称的虚拟主机。因此请放置适当的服务器名称
# 这里。示例:django.devsrv.local
ServerName app_name.com
WSGIDaemonProcess iboyko python-home = / var / www / vhosts / app_name-blog / app_name-blog-env
WSGIProcessGroup%{GLOBAL}
#在此处插入wsgi.py文件的完整路径
WSGIScriptAlias / /var/www/vhosts/app_name-blog/app_name/wsgi.py
< Directory / var / www / vhosts / app_name-blog />
要求全部授予
< /目录>
别名/ static / / var / www / vhosts / app_name-blog / static /
< Directory / var / www / vhosts / app_name-blog / static />
命令拒绝,允许
允许所有人
< /目录>
Alias / media / / var / www / vhosts / app_name-blog / media /
< Directory / var / www / vhosts / app_name-blog / media />
命令拒绝,允许
允许所有人
< /目录>
#Alias / static / admin / /var/www/vhosts/app_name-blog/app_name-blog-env/lib/python3.5/site-packages/django/contri$
#Alias / static / admin / / var / www / vhosts / app_name-blog / static / admin
#PROCESS_NAME =指定此进程的不同名称
#see:https://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess
#PATH / TO / PROJECT_ROOT是项目根目录的完整路径,
#包含您的项目文件
#PATH / TO / VIRTUALENV / ROOT:如果您使用virtualenv指定完整
#path到其目录的路径。
#通常,您必须指定Python的站点包的路径。
#WSGIDaemonProcess {{project_name}} python-path = {{project_directory}}:{{project_directory}} /../ lib $
#WSGIPythonPath /var/www/vhosts/app_name/:/var/www/vhosts/app_name/app_name-site/lib/python3.6/site-packages/
#PROCESS_GROUP指定进程组的不同名称
#see:https://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIProcessGroup
#WSGIProcessGroup {{project_name}}
< /虚拟主机>
1 个答案:
答案 0 :(得分:0)
简而言之,确保安装了djangocms_admin_style
,确保在STATIC_ROOT
文件中设置settings.py
变量,并指向静态文件所在的绝对路径服务是解决这个问题的先决条件。
pip install djangocms_admin_style
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_ROOT = os.path.join(BASE_DIR, "static")
最后,运行以下命令可以解决问题:
python manage.py collectstatic
wsgi.py文件保持不变。