Jane Smith
Jane Smith

Reputation: 75

Html is not extending correctly only base.html

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 class="navbar">
          <ul class="navbar-nav">
            <li class="nav-item">Home</li>
            <li class="nav-item">About</li>
    
            <!-- Dropdown will go here -->
            
          </nav>
    
    
          {% block body_block %} 
          
          {% endblock %}
        </body>
      </body>
    </html>

Home.html


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

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

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

Upvotes: 0

Views: 47

Answers (2)

Mahammadhusain kadiwala
Mahammadhusain kadiwala

Reputation: 3650

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

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

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

Upvotes: 1

jatin yadav
jatin yadav

Reputation: 1

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

Upvotes: 0

Related Questions