Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.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
Html Django静态文件引用_Html_Django Templates_Django Staticfiles - Fatal编程技术网

Html Django静态文件引用

Html Django静态文件引用,html,django-templates,django-staticfiles,Html,Django Templates,Django Staticfiles,我试图将一些图片从静态文件夹链接到我的Django应用程序,但它在templates目录中创建了一个新的静态文件夹 我的HTML: {% load static %} <!DOCTYPE html> {% extends 'milk_app/base.html' %} {% load staticfiles %} {% block title_block %} Homepage {% endblock %} {% block body_block %}

我试图将一些图片从静态文件夹链接到我的Django应用程序,但它在templates目录中创建了一个新的静态文件夹

我的HTML

{% load static %}
<!DOCTYPE html>
{% extends 'milk_app/base.html' %}

{% load staticfiles %} 


{% block title_block %}
    Homepage
    

{% endblock %}

{% block body_block %}

<!-- Home page for Hosts -->
{% if user.userprofile.account == "Host" %}
    <div class="container">
        <div class="row">
            
            <div class="home_hover_pictures col-4">
                <a href="home.php"><img class="img-responsive" src="{% static 'images/listing-property.jpg' %}"></a>
                <h4>Create a new listing</h4>
            </div>
            
            <div class="home_hover_pictures col-4">
                <a href="home.php"><img class="img-responsive" src="{% static 'images/your-properties.jpg' %}"></a>
                <h4>Show your rented properties</h4>
            </div>

            <div class="home_hover_pictures col-4">
                <a href="home.php"><img class="img-responsive" src="{% static 'images/scroll-others.jpg' %}"></a>
                <h4>Scroll other properties</h4>
            </div>
        </div>
    </div>

<!-- Home page for Tenants (not the beer) -->
{% elif user.userprofile.account == 'Tenant' %}

<!-- Home page for not logged users -->
{% else %}
<br><br>    
    <section >
        <div>
            
        </div>
    </section>
    
{% endif %}


{% endblock %}
因此,我的VS代码正在某个地方创建一个新文件,我不想创建它,同时创建一个新的.jpg文件,这是没有意义的。为什么会这样呢?

如中所述,如果您的资产未绑定到特定的应用程序,您可以在设置中定义目录列表(STATICFILES\u DIRS)

STATICFILES_DIRS = [
    BASE_DIR / "static"
]

我把它定义为:STATICFILES\u DIRS=[STATIC\u DIR,]这样行吗?当STATIC_DIR=os.path.join(BASE_DIR,'STATIC')时,请从settings.py文件中显示与静态文件相关的所有设置。请查看此q/a
STATICFILES_DIRS = [
    BASE_DIR / "static"
]