0

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!

LBJ33
  • 425
  • 11
  • 29
  • 1
    Does this answer your question? [Difference between static STATIC\_URL and STATIC\_ROOT on Django](https://stackoverflow.com/questions/8687927/difference-between-static-static-url-and-static-root-on-django) – markwalker_ Jan 03 '21 at 21:55

2 Answers2

1

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.

tim-mccurrach
  • 6,395
  • 4
  • 23
  • 41
  • Deleting that worked for the production side, but now on my local development side none of the static files are loading.. Any idea how I would fix that? – LBJ33 Jan 04 '21 at 12:09
0

I had this happen too!

To solve, add slashes (/) to the path:

STATICFILES_DIRS = [os.path.join(BASE_DIR, '/static/')]

That’s working very well!

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Timeless
  • 104
  • 5