![](/img/trans.png)
[英]Django: STATIC_ROOT STATIC_ROOT can't join with BASE_DIR path
[英]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.