【发布时间】:2013-01-12 00:14:06
【问题描述】:
我在 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 管理员会正确显示。我尝试从
更改我的 Nginx conf 文件location /admin/media/ {
root /path/to/django/contrib;
}
到
location /admin/media/ {
root /path/to/grappelli;
}
没有变化。谁能告诉我哪里出错了?
【问题讨论】:
-
我有同样的问题,但我使用的是 django 服务器
-
这很有趣,因为我的设置在开发服务器上运行良好,所以无论你在开发中没有做什么,我在生产中都没有做!请告诉我你是如何修复它的。
-
我也有同样的问题。到目前为止,这似乎是一个我还不知道的 Grappelli 问题。
标签: django nginx gunicorn django-grappelli