Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.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
Python 在Django中访问静态文件_Python_Django_Django Staticfiles_Web Frameworks_Django Static - Fatal编程技术网

Python 在Django中访问静态文件

Python 在Django中访问静态文件,python,django,django-staticfiles,web-frameworks,django-static,Python,Django,Django Staticfiles,Web Frameworks,Django Static,我的Django项目结构如下: │ db.sqlite3 │ manage.py │ ├───static │ │ 1.jpg │ │ bg1.jpg │ │ │ └───css │ login.css │ ├───templates │ home.html │ login.html │ regis

我的Django项目结构如下:

    │   db.sqlite3
    │   manage.py
    │
    ├───static
    │   │   1.jpg
    │   │   bg1.jpg
    │   │
    │   └───css
    │           login.css
    │
    ├───templates
    │       home.html
    │       login.html
    │       register.html
    │
    ├───User
    │   │   admin.py
    │   │   apps.py
    │   │   models.py
    │   │   tests.py
    │   │   urls.py
    │   │   views.py
    │   │   __init__.py
    │   │
    │   ├───migrations
    │   │   │   __init__.py
    │   │   │
    │   │   └───__pycache__
    │   │           __init__.cpython-38.pyc
    │   │
    │   └───__pycache__
    │           admin.cpython-38.pyc
    │           apps.cpython-38.pyc
    │           models.cpython-38.pyc
    │           urls.cpython-38.pyc
    │           views.cpython-38.pyc
    │           __init__.cpython-38.pyc
    │
    └───Website
        │   asgi.py
        │   settings.py
        │   urls.py
        │   wsgi.py
        │   __init__.py
        │
        └───__pycache__
                settings.cpython-38.pyc
                urls.cpython-38.pyc
                wsgi.cpython-38.pyc
                __init__.cpython-38.pyc
设置.py “”“

和my Register.html文件

{% load static %}
<html>
<head>
    <title></title>
    <style>

    body
    {
    background:url({% static 'bg1.jpg' %});
    }
    </style>
</head>
<body>
<img src="{% static '1.jpg' %}">
<h1>    HELOO </h1>
</body>
</html>
{%load static%}
身体
{
背景:url({%static'bg1.jpg%});
}
希鲁

我已经加载了静态文件以及静态文件的路径,但仍然无法找到我在html页面中提供的图像。使用模板文件夹时没有问题,但仅对于静态文件夹,我的项目无法获取图像并将其粘贴到浏览器上。

在setting.py中将STATICFILES\u DIR更改为STATICFILES\u DIRS有助于这是一个错误。
多亏了Afzal Saiyed

在设置中将STATICFILES\u DIR更改为STATICFILES\u DIRS
{% load static %}
<html>
<head>
    <title></title>
    <style>

    body
    {
    background:url({% static 'bg1.jpg' %});
    }
    </style>
</head>
<body>
<img src="{% static '1.jpg' %}">
<h1>    HELOO </h1>
</body>
</html>