我在ubuntu服务器上运行django 1.4和grappelli 2.4.3,我在生产时通过Windows网络系统查看.当我使用RDP在Ubuntu机器上查看它时,在开发服务器上一切正常.
settings.py的相关部分是:
STATIC_ROOT = os.path.join(os.path.dirname(__file__), '../03_static_files/collected/')
STATIC_URL = '/static/'
STATICFILES_Dirs = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(os.path.dirname(__file__), '../03_static_files/'),
os.path.join(os.path.dirname(__file__), '../03_static_files/admin/'),
os.path.join(os.path.dirname(__file__), '../03_static_files/filebrowser/'),
os.path.join(os.path.dirname(__file__), '../03_static_files/grappelli/'),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# apps I added but didn't create
'south',
'grappelli',
'filebrowser',
'tinymce',
'haystack',
'gunicorn',
'debug_toolbar',
'taggit',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
# apps I created
'community',
'fts',
'guidance',
'news',
)
我运行了collectstatic,但管理站点显然只是部分呈现.它肯定会拿起一些CSS,因为有些元素是样式化的.但它并没有吸引其他人,因为它看起来很混乱.我的Nginx或Gunicorn错误日志都没有显示任何404,如果我直接将浏览器指向他们,我可以下载所有的css和js文件.
管理站点目前在IE8和IE9中都是这样的:
该网站的其他一切运行良好. Django调试工具栏说(工作)开发服务器版本和上面的生产版本呈现相同的模板.删除grappelli时,正常的django admin会正常显示.我试过更改我的Nginx配置文件
location /admin/media/ {
root /path/to/django/contrib;
}
至
location /admin/media/ {
root /path/to/grappelli;
}
没有变化.谁能告诉我哪里出错了?
解决方法:
在那里检查静态媒体.
检查所有那些os这些设置…
STATIC_URL = '/static/'
STATIC_ROOT is something like os.path.join(PROJECT_PATH, "static"),
ADMIN_MEDIA_PREFIX = '/static/grappelli/' (or whatever your static directory is)
接下来检查你的
DEBUG = False or True ?
TEMPLATE_DEBUG = DEBUG
另一个例子…
STATIC_URL = '/static/'
STATIC_ROOT = '/home/foo/devel/static'
MEDIA_URL = '/media/'
MEDIA_ROOT = '/home/foo/devel/media'
# the following is deprecated but is it seems grappelly requires it
ADMIN_MEDIA_PREFIX = STATIC_URL + "grappelli/"
STATIC_FILES = ()
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。