0
我嘗試在Heroku上發佈django項目,但是我遇到了靜態文件的問題。 這是我的我的配置:使用django和Heroku的靜態文件夾無效
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
# Extra places for collectstatic to find static files.
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
但是Heroku的返回:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/build_02a3e2abd7f176139303f077e32a2e9b/static'
remote:
remote: ! Error while running '$ python manage.py collectstatic --noinput'.
remote: See traceback above for details.
remote:
remote: You may need to update application code to resolve this error.
remote: Or, you can disable collectstatic for this application:
remote:
remote: $ heroku config:set DISABLE_COLLECTSTATIC=1
remote:
remote: https://devcenter.heroku.com/articles/django-assets
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
我出的解決方案,我理解這個問題,但不知道如何定勢它:( 我的項目結構如下像:
├── Procfile
├── manage.py
├── my_project
│ ├── __init__.py
│ ├── settings
│ │ ├── __init__.py
│ │ ├── base.py
│ │ ├── dev.py
│ │ └── prod.py
│ ├── urls.py
│ └── wsgi.py
├── requirements.txt
├── runtime.txt
├── static
└── staticfiles
約Django的或Heroku的文件時,設置由環境:(
分裂不解釋