[Answered ]-Errors with deployment in Django app using Heroku

2👍

The error log you’re getting gives a good description of the problem:

…ImproperlyConfigured: You’re using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.

You’re running the manage.py collectstatic command as part of deployment. This should collect all your static files from your various STATICFILES_DIRS and put them into one folder: STATIC_ROOT for your webserver (Apache or Nginx) to serve them.

You need to select a folder for STATIC_ROOT so that collectstatic can put your static files into that folder, per the documentation here.

You’ll also have to make sure the static files directories are properly configured and that your webserver is properly calling them, but the above is the current crux of the problem.

0👍

Well, you are using debug mode false. The error occurs because you haven’t correctly set static files directory for application. In your settings.py paste the code below.

#default static url
STATIC_URL = '/static/'

#this when debug is True, the project should look where static folder located, set STATICFILES_DIRS accordingly:
if DEBUG:
   STATICFILES_DIRS = [
   os.path.join(BASE_DIR, 'static'),
   ]
#when you change environemnt to production, STATIC_ROOT should be given. 
else:
   STATIC_ROOT = os.path.join(BASE_DIR,'static')

#for media files add followings:
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

Leave a comment