首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Django web应用程序heroku部署过程中的静态文件问题

Django web应用程序heroku部署过程中的静态文件问题
EN

Stack Overflow用户
提问于 2021-03-22 12:17:22
回答 1查看 128关注 0票数 0

我正在尝试部署我的Django web应用程序,但我遇到了一些错误。我学习了一些教程,但它们没有帮助我。此外,我有所有必要的文件,如Procfilerequirements.txt。甚至我也试图将STATIC_ROOT改为staticfilesstatic,但没有效果。

代码语言:javascript
复制
   FileNotFoundError: [Errno 2] No such file or directory: '/tmp/build_4dca6fca/static'
   Error while running '$ python manage.py collectstatic --noinput'.
   See traceback above for details.
   You may need to update application code to resolve this error.
   Or, you can disable collectstatic for this application:
   $ heroku config:set DISABLE_COLLECTSTATIC=1
   https://devcenter.heroku.com/articles/django-assets
   Push rejected, failed to compile Python app.
   Push failed

settings.py

代码语言:javascript
复制
DEBUG = False
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',   # added whitenoise
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static')
]

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

Procfile

代码语言:javascript
复制
web: gunicorn portfolio.wsgi --log-file -
EN

回答 1

Stack Overflow用户

发布于 2022-02-22 13:21:42

尝试在BASE_DIR中更改settings.py变量

代码语言:javascript
复制
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66745864

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档