Django grappelli似乎无法看到它的所有媒体文件

weixin_38080713 2019-09-12 01:36:10
我在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; } 没有变化.谁能告诉我哪里出错了?
...全文
41 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38091030 2019-09-12
  • 打赏
  • 举报
回复
在那里检查静态媒体. 检查所有那些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 如果为false,它将使用nginx提供文件,但不会 另一个例子… 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', )

476

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧