简体   繁体   中英

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. 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:

 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.

Thanks,

Edit: As required Requirements.txt pasted:

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 . Specially the STATICFILES_DIRS which will set a place to collect the statics for production.

Please follow this 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. Let me know.

Please use whitenoise to deploy static files on heroku.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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