繁体   English   中英

使用静态根路径django的heroku deploy错误。 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/'

这些是我当前的根URL:

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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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