简体   繁体   English

在 Heroku 上部署 Django 应用程序需要支持

[英]Support needed for Django app deployment on Heroku

I have an app I'd like to deploy on Heroku. Not finished yet but it's now a requirement from my teacher.我有一个应用程序,我想在 Heroku 上部署。尚未完成,但现在是我老师的要求。 I created an account and app on heroku and use the GitHub deployment method but when I click on deploy branch I have the following type of error:我在 heroku 上创建了一个帐户和应用程序并使用 GitHub 部署方法但是当我单击部署分支时出现以下类型的错误:

 FileNotFoundError: [Errno 2] No such file or directory: '/tmp/build_0f3c3e792cd2015b5d316aad8cf28d6c/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, 

Can you help me understand the error and solve it?你能帮我理解错误并解决它吗?

I'd like to use this deployment method if possible as I am very much a begginer in git too and I'd like to avoid doing it with CLI for now.如果可能的话,我想使用这种部署方法,因为我也是 git 的初学者,我想暂时避免使用 CLI。

Thanks,谢谢,

Edit: As required Requirements.txt pasted:编辑:根据需要粘贴 Requirements.txt:

asgiref==3.2.3
Brotli==1.0.7
certifi==2020.4.5.1
chardet==3.0.4
dj-database-url==0.5.0
Django==3.0.3
django-crispy-forms==1.9.0
django-heroku==0.3.1
gunicorn==20.0.4
idna==2.9
psycopg2==2.8.5
pytz==2019.3
requests==2.23.0
six==1.14.0
sqlparse==0.3.0
urllib3==1.25.9
whitenoise==5.0.1

I don't know what is the state of your settings but make sure your static urls are all created in settings.py .我不知道您的设置的 state 是什么,但请确保您的 static 网址都是在settings.py中创建的。 Specially the STATICFILES_DIRS which will set a place to collect the statics for production.特别是STATICFILES_DIRS ,它将设置一个位置来收集用于生产的静态信息。

Please follow this Heroku KB: https://devcenter.heroku.com/articles/django-assets |请关注此 Heroku KB: https://devcenter.heroku.com/articles/django-assets |

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
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'),
)

Then it should collect static in the right folder.然后它应该在正确的文件夹中收集 static。 Let me know.让我知道。

Please use whitenoise to deploy static files on heroku.请使用whitenoise在 heroku 上部署 static 个文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM