【发布时间】:2014-07-22 05:04:05
【问题描述】:
我有一台运行 OS X 10.9.3 的 Mac。我正在尝试设置由 gunicorn 提供的 PostgreSQL 数据库支持的 Django 应用程序,并使用 NGINX 提供的静态资产。我是 Django 的老手,MySQL 与开发服务器 (manage.py runserver) 一起运行。但我不熟悉使用 virtualenv、gunicorn 和 NGINX 进行设置。所以我按照here 的说明进行操作。
我的 Django 项目正在http://localhost:3026 成功服务。作为数据库连接测试,我想看看 Django Admin 界面。我访问了http://localhost:3026/admin/。我在下面附上了屏幕截图。
为什么这个管理页面看起来这么难看?它缺少它应该有的必要的图形界面和 css?看起来 NGINX 没有正确地提供这些静态资产。如何排查和解决此问题?
我什至做了python manage.py collectstatic。这样就成功地将所有静态文件复制到了它们应该(我认为?)在/opt/myenv/static 中的位置。您可以看到该命令here 的输出。然后我重新启动了 gunicorn 和 nginx。我以为那会解决它。但不幸的是它没有。问题依然存在。在我的 Django settings.py 文件中,我配置了 STATIC 变量如下:
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'djangobower.finders.BowerFinder',
)
STATIC_ROOT = "/opt/myenv/static/"
STATIC_URL = '/static/'
【问题讨论】: