Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django collectstatic收集静态文件,但它们';你没有在网页上加载_Django_Static Files_Django Deployment - Fatal编程技术网

Django collectstatic收集静态文件,但它们';你没有在网页上加载

Django collectstatic收集静态文件,但它们';你没有在网页上加载,django,static-files,django-deployment,Django,Static Files,Django Deployment,我正在A2主机上部署我的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')] my URL.py: urlpa

我正在A2主机上部署我的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')]
my URL.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
。它正在创建一个
静态
文件夹,其文件结构包括
管理
和该管理文件夹中的子文件夹。我的图像和css文件出现在新生成的
静态
文件中(在基本文件夹中),但css和我的图像都没有显示在我的网页上(我一直在重新启动服务器)

我的html模板中指向css文件的链接是:

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

谢谢。

{%load static%}在html模板或base.htmlHello中使用它。我已经在html文件的顶部这样做了。谢谢。显示静态目录树。我加上去的
/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
...