静态根路径 django 的 heroku 部署错误。 static_root 未设置为文件系统路径

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

当我尝试部署时,根据 heroku,我的静态文件设置配置不正确。毫无疑问,这是错误的,因为我仍然不了解设置静态文件的正确方法。

我 运行 在我的机器上收集静电,它确实有效。我将提供我所要求的信息,以帮助我解决这个问题。我将继续研究并希望能找到解决方案。

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/'

这些是我当前的根网址:

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)),
]

STATIC_URL 添加到您的 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)