Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.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_Html_Css_Python 3.x_Django - Fatal编程技术网

Python 为什么每次我尝试将图像添加到django项目时都会出错?

Python 为什么每次我尝试将图像添加到django项目时都会出错?,python,html,css,python-3.x,django,Python,Html,Css,Python 3.x,Django,base.html的思想不是重复我在几乎所有页面中都需要的一些代码。。。我可以轻松地{%extends'homepage/base.html%}。在我需要的每一页上 在下面签出my base.html 1。(base.html) {%load static%} {%if title%} 阿马尔餐厅{{title} {%else%} 阿马尔餐厅 {%endif%} {%block content%} {%endblock内容%} 这是index.html,在这里我{%extends'homepa

base.html的思想不是重复我在几乎所有页面中都需要的一些代码。。。我可以轻松地{%extends'homepage/base.html%}。在我需要的每一页上

在下面签出my base.html

1。(base.html)
{%load static%}
{%if title%}
阿马尔餐厅{{title}
{%else%}
阿马尔餐厅
{%endif%}
{%block content%}
{%endblock内容%}
这是index.html,在这里我{%extends'homepage/base.html%}。除了我的图像,其他一切都很好

在下面签出我的index.html

2。(index.html)
{%extends'主页/base.html%}
{%block content%}
再见,垃圾食品。 你好,超级健康餐。 我饿了 下单 吃快餐,而不是快餐

您好,我们是Omnifood,您新推出的优质食品配送服务。我们知道你总是很忙。没有时间做饭。所以让我们来解决这个问题,我们真的很擅长,我们保证!

最多365天/年 再也不要做饭了!我们是认真的。我们的订阅计划包括高达365天/年的覆盖范围。如果这是你的风格,你也可以选择更灵活的订购方式。

20分钟后准备好 你只需要20分钟就可以享受到送回家的美味和超级健康的饭菜。我们与每个城市最好的厨师合作,确保您100%满意。

100%有机 我们所有的蔬菜都是新鲜的、有机的和本地的。动物在没有添加激素或抗生素的情况下被饲养。对你的健康、环境都有好处,而且味道也更好!

点什么 我们不限制您的创造力,这意味着您可以随意订购。您也可以从包含100多种美味佳肴的菜单中选择。这取决于你!

{%endblock内容%}
在我的静态目录中,我有另一个目录主页,主页内有图像、css和js目录。 这样地:
静态/主页/图像

您还必须在
index.html
中添加
{%load static%}

您“遇到”了什么错误?请将其粘贴到您的帖子中。我刚刚添加了错误消息的屏幕截图,请检查。。谢谢。请尝试签出
{%load static%}
您也需要在
index.html
中编写它(加载它的父模板并不意味着子模板可以直接使用它),因为您在那里使用标记。将它直接写在
{%extends'homepage/base.html%}
下面,谢谢@AbdulAzizBarkat它工作得很好。。。我差点把我的笔记本电脑弄坏了。。。除息的
1. (base.html) 
    

        {% load static %}
        <!DOCTYPE html>
        <html lang="en">
        <head>
          <!-- Required meta tags -->
          <meta charset="utf-8">
          <meta name="viewport" content="width=device-width, initial-scale=1">

          <!--fonts-->
          <link href="https://fonts.googleapis.com/css2? 
   family=Comfortaa:wght@300;400;500;600;700&display=swap" rel="stylesheet">
          <link href="https://fonts.googleapis.com/css2?family=Niconne&family=Satisfy&display=swap" 
   rel="stylesheet">   

          <!-- Bootstrap CSS -->
          <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" 
   rel="stylesheet" integrity="sha384- 
   +0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
          <link rel="stylesheet" href="{% static 'homepage/css/styles.css' %}">

          {% if title %}
            <title>Amal Restaurant - {{ title }}</title>
          {% else %}
            <title>Amal Restaurant</title>
          {% endif %}
        </head>
        <body>
          {% block content %}

          {% endblock content %}

          <!-- Option 1: Bootstrap Bundle with Popper -->
          <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" 
   integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" 
   crossorigin="anonymous"></script>

          <!-- Option 2: Separate Popper and Bootstrap JS -->
          <!--
          <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" 
   integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" 
   crossorigin="anonymous"></script>
          <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.min.js" 
   integrity="sha384-Atwg2Pkwv9vp0ygtn1JAojH0nYbwNJLPhwyoVbhoPwBhjQPR5VtM2+xf0Uwh9KtT" 
   crossorigin="anonymous"></script>
          -->
          <!--jquery cdn-->
          <script src="https://code.jquery.com/jquery-3.6.0.min.js" 
   integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"> 
          </script>
          <!--local js files-->
          <script src="{% static 'homepage/js/jquery.js' %}"></script>
          <script src="{% static 'homepage/js/main.js' %}"></script>

       </body>
       </html>
2. (index.html)

        {% extends 'homepage/base.html' %}

{% block content %}
   <header class="header">
       <div id="logo">
           <img src="images/logo-white.png" alt="logo">
       </div>
       <div id="nav-bar">
           <ul>
               <li id="delivery"><a href="#">Food deliveries</a></li>
               <li id="works"><a href="#">How it works</a></li>
               <li id="cities"><a href="#">Our cities</a></li>
               <li id="sign"><a href="#">Sign up</a></li>      
           </ul>
       </div>

       <div class="header-text">
           <h1 id="header-text-main">
               <span id="header-text-primary">Goodbye junk food.</span>
               <span id="header-text-secondary">Hello super healthy meals.</span>
           </h1>
           <div class="header-buttons">
               <span id="hungry">I'm hungry</span>
               <span id="more">Place Your Order</span>
           </div>
       </div>
   </header>
   <section class="main">
       <h2 class="headers">Get food fast — not fast food</h2>
       <p class="texts">
           Hello, we're Omnifood, your new premium food delivery service. We know you're always busy. No time for cooking. So let us take care of that, we're really good at it, we promise!
       </p>
       <div class="container">
           <div class="row">
               <div class="col-xl-3 col-lg-3 col-md-6 col-sm-6 col-xs-12">
                   <i class="glyphicon glyphicon-repeat"></i>
                   <h3>Up to 365 days/year</h3>
                   <p>
                       Never cook again! We really mean that. Our subscription plans include up to 365 days/year coverage. You can also choose to order more flexibly if that's your style.
                   </p>
               </div>
               <div class="col-xl-3 col-lg-3 col-md-6 col-sm-6 col-xs-12">
                   <i class="glyphicon glyphicon-time"></i>
                   <h3>Ready in 20 minutes</h3>
                   <p>
                       You're only twenty minutes away from your delicious and super healthy meals delivered right to your home. We work with the best chefs in each town to ensure that you're 100% happy.
                   </p>
               </div>
               <div class="col-xl-3 col-lg-3 col-md-6 col-sm-6 col-xs-12">
                   <i class="glyphicon glyphicon-cutlery"></i>
                   <h3>100% organic</h3>
                   <p>
                       All our vegetables are fresh, organic and local. Animals are raised without added hormones or antibiotics. Good for your health, the environment, and it also tastes better!
                   </p>
               </div>
               <div class="col-xl-3 col-lg-3 col-md-6 col-sm-6 col-xs-12">
                   <i class="glyphicon glyphicon-shopping-cart"></i>
                   <h3>Order anything</h3>
                   <p>
                       We don't limit your creativity, which means you can order whatever you feel like. You can also choose from our menu containing over 100 delicious meals. It's up to you!
                   </p>
               </div>
           </div>
       </div>
   </section>

   <section class="gallery">
       <div class="container-fluid">
           <div class="row text-center text-lg-left">
               <div class="col-lg-3 col-md-4 col-6">
                   <a href="#" class="mb-4 h-100">
                   <img src="{% static 'homepage/images/amala.jpeg' %}">
                   </a>
               </div>
               <div class="col-lg-3 col-md-4 col-6">
                   <a href="#" class="mb-4 h-100">
                   <img src="{% static 'homepage/images/semo.jpeg' %}">
                   </a>
               </div>
               <div class="col-lg-3 col-md-4 col-6">
                   <a href="#" class="mb-4 h-100">
                   <img src="{% static 'homepage/images/jollof.jpeg' %}">
                   </a>
               </div>
           </div>
       </div>
   </section>

{% endblock content %}