[英]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. 尝试部署时,根据heroku未正确配置我的静态文件设置。 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: 这些是我当前的根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)),
]
Add STATIC_URL
to your urlpatterns
. 将
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.