collectstatic收集静态文件,但未在网页上加载

我正在A2 Hosting上部署Django网站。

我可以显示页面,但没有加载静态文件(图像/ css)。

我在settings.py中有这个

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR,'static')

ROOT_PATH = os.path.dirname(__file__)
STATIcfileS_DIRS = [os.path.join(ROOT_PATH,'static')]

我的urls.py:

urlpatterns = [
    path('admin/',admin.site.urls),path('',include('mysite.urls')),url(r'^$',TemplateView.as_view(template_name='static_pages/index.html'),name='home'),] + static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)

urlpatterns += static(settings.STATIC_URL,document_root=settings.STATIC_ROOT)

我正在终端中运行python manage.py collectstatic。它正在创建一个static文件夹,其文件结构包括该管理文件夹中的admin和子文件夹。我的图像和CSS文件显示在新生成的static文件中(在基本文件夹中),而CSS和我的图像均未显示在网页上(我一直在重新启动服务器)。

我的html模板中的CSS文件的链接为:

<link rel="stylesheet" href="{% static 'style.css' %}" type="text/css">

这是在共享主机上完成的,我已将debug设置为false,并且可以在开发中使用。

/home/mysite
->etc
->mysite
-->__pycache__
-->webpage
--->static
---->webpage
----->image.jpg
----->style.css
--->templates
---->webpage
----->index.html
-->main_webpage
--->settings.py
-->public
-->static_files (generated by collectstatic)
--->admin
--->image1
--->style.css
-->template
-->tmp
->logs
...

谢谢。

xiongyong3036 回答:collectstatic收集静态文件,但未在网页上加载

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/1499991.html

大家都在问