简体   繁体   English

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

[英]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.

相关问题 Django:STATIC_ROOT STATIC_ROOT 无法加入 BASE_DIR 路径 - Django: STATIC_ROOT STATIC_ROOT can't join with BASE_DIR path Django 3.0.7 无法更改 STATIC_ROOT 路径 - Django 3.0.7 unable to change STATIC_ROOT path 在 Django 中使用 heroku 时出现 STATIC_ROOT 错误 - Having an Error with STATIC_ROOT when using heroku in Django Django 中的 STATIC_ROOT 设置 - STATIC_ROOT setting in Django django.core.exceptions.ImproperlyConfigured:您使用的是静态文件应用程序,而没有将 STATIC_ROOT 设置设置为文件系统路径 - django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path Python Django:您使用的是静态文件应用程序,而没有将 STATIC_ROOT 设置设置为文件系统路径 - Python Django: You're using the staticfiles app without having set the STATIC_ROOT setting setting to a filesystem path 您正在使用 staticfiles 应用程序,而没有将 STATIC_ROOT 设置设置为文件系统路径 - You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path 在Django settings.py文件中指定STATIC_ROOT STATIC_URL时出错 - Getting error in specifying STATIC_ROOT STATIC_URL in Django settings.py file 配置不当:您使用的是staticfiles应用,而未将STATIC_ROOT设置设置为文件系统路径 - ImproperlyConfigured:You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path 找不到 static 文件。 我收到未设置“STATIC_ROOT”的错误 - Cannot locate a static file. I get an error that 'STATIC_ROOT' is not set
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM