简体   繁体   中英

heroku deploy error with static root path django. static_root not set to file system path

my static files settings are improperly configured according to heroku when I attempt to deploy. I am without doubt this is false as I still lack understanding of the proper way to set up static files.

I have ran collect static on my machine and it did work. I will provide the information my ask is to help me clear this up. I am going to continue to research and hope to come with a solution.

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
#angular distro root
ANGULAR_APP_DIR = os.path.join(BASE_DIR, 'frontend/dist')


STATICFILES_DIRS = [
    os.path.join(ANGULAR_APP_DIR),

]


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'

these are my current root urls:

urlpatterns = [
    url(r'^$', serve, kwargs={'path': 'index.html'}),
    url(r'^(?!/?static/)(?!/?media/)(?P<path>.*\..*)$',RedirectView.as_view(url='/static/%(path)s', permanent=False)),
    url(r'api/',include(rootapi)),
]

Add STATIC_URL to your urlpatterns .

from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    # your url patterns
]

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM