0

When I run python manage.py collectstatic --noinput in my local machine, it works fine. But when heroku runs python manage.py collectstatic --noinput it gives error like this: for entry in os.scandir(path) FileNotFoundError: [Errno 2] No such file or directory: '/tmp/build_5d05d870/static'

My project directory seems like this:

mysite-----|libooki(app)----------|migrations
           |----------------------|init.py
           |----------------------|admin.py
           |----------------------|........
-----------|media
-----------|media_cdn
-----------|mysite
-----------|static|--------------|css|------style.css
-----------|staticfiles
-----------|templates
-----------|.........

My settings.py seems like this. (I followed this article: https://devcenter.heroku.com/articles/django-assets)

from pathlib import Path
import os
import django_heroku



BASE_DIR = Path(__file__).resolve().parent.parent
TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates')

INSTALLED_APPS = [
    ........,
    'libooki',
]

MIDDLEWARE = [
    ...........................................,
    'whitenoise.middleware.WhiteNoiseMiddleware',
]

WSGI_APPLICATION = 'mysite.wsgi.application'

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

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)
MEDIA_ROOT = os.path.join(BASE_DIR,'media_cdn')
MEDIA_URL = '/media/'
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
django_heroku.settings(locals())
Arshmaan
  • 1
  • 2
  • 1
    I answered a very similar question here https://stackoverflow.com/questions/65898805/django-app-getting-server-error-500-on-local-host-when-debug-false/65924431 I hope this can help you – Dos Feb 21 '21 at 21:13
  • Does this answer your question? [Django app getting server error 500 on local host when Debug = False](https://stackoverflow.com/questions/65898805/django-app-getting-server-error-500-on-local-host-when-debug-false) – BogdanBiv Feb 21 '21 at 22:08

0 Answers0