Reputation: 71
I am new to django ! When I use the commad, git push heroku master
I get this error.
remote: django.core.exceptions.ImproperlyConfigured: The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting
remote:
remote: ! Error while running '$ python manage.py collectstatic --noinput'.
remote: See traceback above for details.
remote:
remote: You may need to update application code to resolve this error.
remote: Or, you can disable collectstatic for this application:
remote:
remote: $ heroku config:set DISABLE_COLLECTSTATIC=1
My static files declarations are :
STATIC_URL = '/static/'
# set for the Heroku deployment.
import dj_database_url
DATABASES = {
'default': dj_database_url.config(default='postgres://localhost')
}
#make reuqest.is_secure admit X-Forwarded-Proto
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# support all the host header
ALLOWED_HOSTS = ['*']
#static configuration
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
My requirements.txt/runtime.txt/Procfile are all good, I googled a lot, Even tried the whitenoise, still I cannot fix it, so can someone help me? Thanks a lot!
My requirements.txt are like below: dj-database-url==0.4.2
dj-static==0.0.6
Django==1.11.1
django-bootstrap3==8.2.3
gunicorn==19.7.1
pytz==2017.2
static3==0.7.0
IF I do heroku config:set DISABLE_COLLECTSTATIC=1
I can push successfully, but the blog page does not show out because of some error.
Upvotes: 2
Views: 6975
Reputation: 63
You have to put in settings File STATIC_ROOT
conf. The best you can do in production is serve static files through amazon s3 or another cdn so you don't overload your server.
See the Django static files docs for more information.
Upvotes: 0