Home > Mobile >  Html is not extending correctly only base.html
Html is not extending correctly only base.html

Time:09-12

When trying to extend from base.html my home.html is not showing when at the url that shows home.html only the base.html is showing. I can't seem to figure out what the problem without extending my home.html shows up perfectly but when extending from base.html it seems like it doesn't want to work

Base.html


  {% load static %}
    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <link rel="stylesheet" href={% static 'css\base.css'%}
    
        
      </head>
      <body>
        <body>
    
        <nav >
          <ul >
            <li >Home</li>
            <li >About</li>
    
            <!-- Dropdown will go here -->
            
          </nav>
    
    
          {% block body_block %} 
          
          {% endblock %}
        </body>
      </body>
    </html>

Home.html


    {% extends 'base.html' %} {% load static %}

<div >
  <div >NEW RENTALS</div>
  {% for List in listings %}
  <div >
    <img src="{% static List.itempicture %}" alt="" />
    <div >
      <h1>{{List.title}}</h1>
      <p>{{List.about}}</p>

      <a  href="{{ List.get_absolute_url }}">Contact</a>
    </div>
  </div>
  {% endfor %}
</div>
<link rel="stylesheet" href={% static 'css\home.css'%}

CodePudding user response:

Put home.html code between {% block body_block %} and {% endblock body_block %}

CodePudding user response:

put a block of the body in your home.html like this...

{% block body_block %}
  <div >
    <div >NEW RENTALS</div>
    {% for List in listings %}
    <div >
      <img src="{% static List.itempicture %}" alt="" />
      <div >
        <h1>{{List.title}}</h1>
        <p>{{List.about}}</p>

        <a  href="{{ List.get_absolute_url }}">Contact</a>
      </div>
    </div>
    {% endfor %}
  </div>
{% endblock body_block %}
  • Related