I've been trying to get my project up on Heroku for almost 2 days now! Worked through a lot of problems but now I can't seem to migrate the new database due to an error with static files. All of my pages on website are live and working except one page, I was getting a 500 error. I turned debug on to see what was going on and it needs the new database to be migrated.
I run the command
heroku run python manage.py migrate
but am getting the following error:
SystemCheckError: System check identified some issues:
ERRORS:
?: (staticfiles.E002) The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting.
Here is my relevant base-settings file:
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(os.path.join(__file__, os.pardir))))
STATIC_URL = '/static/'
# STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
and my prod settings:import os
from .base import *
import dj_database_url
DEBUG = True
ADMINS = [
('name', 'email')
]
try:
SECRET_KEY = os.getenv('SECRET_KEY')
except:
print("Error getting key")
ALLOWED_HOSTS = ['*']
DATABASES = {
'default': {
}
}
db_from_env = dj_database_url.config(conn_max_age=600)
DATABASES['default'].update(db_from_env)
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
Any help would be greatly appreciated!! This has been a huge pain getting the website even able to deploy with the static files, and now that I have it up I can't migrate my database because of it! Thanks!
You can delete these line:
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
STATICFILES_DIRS
are for additional directories, beyond STATIC_ROOT
. You have exactly the same thing in your STATIC_ROOT
and STATICFILES_DIRS
so there is no need for the latter. Deleting this should fix your problem.