i have deploy simple blog application on heroku, run on django=1.8.4
, , i'm having issues whit static files.
when open mine application see application error
page, have try debug , find out when commit heroku can't preform collectstatic on mine static folder. else working , heroku showing me build succeeded
can not preform
remote: -----> preparing static assets remote: collectstatic configuration error. debug, run: remote: $ heroku run python bloggy_project/manage.py collectstatic --noinput
so heroku want me debug it. after type
heroku run python bloggy_project/manage.py collectstatic --noinput
error log showing:
running python bloggy_project/manage.py collectstatic --noinput on greenbloggy... up, run.4682 traceback (most recent call last): file "bloggy_project/manage.py", line 10, in <module> execute_from_command_line(sys.argv) file "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line utility.execute() file "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute self.fetch_command(subcommand).run_from_argv(self.argv) file "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 190, in fetch_command klass = load_command_class(app_name, subcommand) file "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 41, in load_command_class return module.command() file "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 32, in __init__ self.storage.path('') file "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 48, in path raise improperlyconfigured("you're using staticfiles app " django.core.exceptions.improperlyconfigured: you're using staticfiles app without having set static_root setting filesystem path.
have tried google answer, i'm confused because have read bunch of posts static files. can show me wrong here can learn , understand something.
mine settings.py:
""" django settings bloggy_project project. generated 'django-admin startproject' using django 1.8.4. more information on file, see https://docs.djangoproject.com/en/1.8/topics/settings/ full list of settings , values, see https://docs.djangoproject.com/en/1.8/ref/settings/ """ # build paths inside project this: os.path.join(base_dir, ...) import os base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # quick-start development settings - unsuitable production # see https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ # security warning: keep secret key used in production secret! secret_key = 'oi1+cyk&9g-n*nyiymkjzt6-es@!g7=edzpx+--rdsj4kw&4&3' # security warning: don't run debug turned on in production! debug = false allowed_hosts = [] # application definition installed_apps = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # local apps 'blog', # third party apps 'django_forms_bootstrap', ) middleware_classes = ( 'django.contrib.sessions.middleware.sessionmiddleware', 'django.middleware.common.commonmiddleware', 'django.middleware.csrf.csrfviewmiddleware', 'django.contrib.auth.middleware.authenticationmiddleware', 'django.contrib.auth.middleware.sessionauthenticationmiddleware', 'django.contrib.messages.middleware.messagemiddleware', 'django.middleware.clickjacking.xframeoptionsmiddleware', 'django.middleware.security.securitymiddleware', ) root_urlconf = 'bloggy_project.urls' templates = [ { 'backend': 'django.template.backends.django.djangotemplates', 'dirs': [os.path.join(base_dir, 'templates')], 'app_dirs': true, 'options': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] wsgi_application = 'bloggy_project.wsgi.application' # database # https://docs.djangoproject.com/en/1.8/ref/settings/#databases databases = { 'default': { 'engine': 'django.db.backends.postgresql_psycopg2', 'name': '', 'user': '', 'password': '', 'host': '', 'post': '', } } # internationalization # https://docs.djangoproject.com/en/1.8/topics/i18n/ language_code = 'en-us' time_zone = 'europe/belgrade' use_i18n = true use_l10n = true use_tz = true # static files (css, javascript, images) # https://docs.djangoproject.com/en/1.8/howto/static-files/ # static asset configuration # allow host hosts/domain names site allowed_hosts = ['*'] # srse database configuration $database_url import dj_database_url databases = {'default': dj_database_url.config()} # honor 'x-forwarded-proto' header request.is_secure() secure_proxy_ssl_header = ('http_x_forwarded_proto', 'https') # try load development_settings.py if exists try: .development_settings import * except exception, e: pass import os media_root = os.path.join(base_dir, 'media') media_url = '/media/' # static_root = os.path.join(base_dir, 'static') static_url = '/static/' staticfiles_dirs = ( os.path.join(base_dir, 'static'), )
update:
when comment out static_root
, ,
heroku run python bloggy_project/manage.py collectstatic --noinput
error log show, , part rely confusing, why error now, if need put static_root
in mine settings.py
?
new error log:
traceback (most recent call last): file "bloggy_project/manage.py", line 10, in <module> execute_from_command_line(sys.argv) file "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line utility.execute() file "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute self.fetch_command(subcommand).run_from_argv(self.argv) file "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 393, in run_from_argv self.execute(*args, **cmd_options) file "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 444, in execute output = self.handle(*args, **options) file "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 168, in handle collected = self.collect() file "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 97, in collect finder in get_finders(): file "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 264, in get_finders yield get_finder(finder_path) file "/app/.heroku/python/lib/python2.7/site-packages/django/utils/lru_cache.py", line 101, in wrapper result = user_function(*args, **kwds) file "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 277, in get_finder return finder() file "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 66, in __init__ "the staticfiles_dirs setting should " django.core.exceptions.improperlyconfigured: staticfiles_dirs setting should not contain static_root setting
you getting error because settings variables static_root
, staticfiles_dirs
contain same path (os.path.join(base_dir, 'static')
). invalid configuration.
static_root
absolute path want django put static files collected using collectstatic
. web server serve static files directory.
staticfiles_dirs
list of directories want collectstatic
when collecting static files. if cannot include static_root
or subdirectory of it.
try removing staticfiles_dirs
setting , see if works. if have put static files in non-standard location change setting include location.
Comments
Post a Comment