Anuj TBE
Anuj TBE

Reputation: 9790

django The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting

I'm deploying a Django application on heroku.

In my settings module, I have configured to host static files like

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

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

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static_cdn', 'media_root')

and urls.py

urlpatterns = urlpatterns + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns = urlpatterns + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

But on deployment to heroku, it gives error as

SystemCheckError: System check identified some issues:

ERRORS:
?: (staticfiles.E002) The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting.

Upvotes: 14

Views: 19821

Answers (2)

jack
jack

Reputation: 51

Maybe this will help:

STATIC_URL = '/static/'
    
if not DEBUG:
    STATIC_ROOT = ''
    
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static/'),
]

Upvotes: 4

Amit
Amit

Reputation: 83

The problem is in the STATIC_ROOT and STATICFILES_DIRS there names cant be same. static root is used for collectstatic command of django. You can remove it if not using it. And can also remove static files dirs if not changing its default position(inside django app) to somewhere else like base or something.

Upvotes: 1

Related Questions