Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Team GDiz
Courses Plus Student 24,942 PointsTemplate inheritance problem
So I was trying out template inheritance in flask but I see only my layout HTML on my web page. I dont see the HTML from my blocks.
My layout.html:
<!doctype html>
<html>
<head>
<title>{% block title %}{% endblock %}</title>
</head>
<body>
{% block body %}{% endblock %}
<p>Yo!</p>
</body>
</html>
My index.html:
{% extends "layout.html" %}
{% block title %} Home {% endblock %}
{% block content %} <h1> Home sweet home - {name}</h1>
{% endblock %}
However all I see is "Yo!" which is in layout.html. Am I doing something wrong? Maybe a syntax problem?
1 Answer
Tatiana Vasilevskaya
Python Web Development Techdegree Graduate 28,600 PointsYou have block body in layout.html and block content in index.html. Use the same block name in both files and it should work.
Team GDiz
Courses Plus Student 24,942 PointsTeam GDiz
Courses Plus Student 24,942 PointsGot the answer. Problem is my layout has a block called body but my index.html tries to override it with the name content.