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

Python

Sergey Shyshka
Sergey Shyshka
8,990 Points

Customizing Django Templates. The solution does not work, please help understand why?

Hi Everybody,

So I'm at the first challenge of the Customizing Django Templates course, and I do not understand, why my code does not work properly? The first task from the challenge "Blocks and Inheritance" is: "Use the {% block %} tag in the layout.html template to add a dynamic section to this template for a header." And here is my solution which passed and allowed me go to the step 2 of the challenge:

{% block header %}{% endblock %}

When I reached Task 2 from this challenge, I mean: "Now, in the "list.html" template, extend "layout.html" (which is in the "code_challenges" directory)." The only way I understand I should complete this task is to write:

{% extends "layout.html" %} in the "list.html" file tab.

But unfortunately I cant pass this challenge, because it throws me "Bummer! Try again!" Do not understand why, any ideas?

Many thanks in advance and sorry for my non-perfect English, I'm from Ukraine.

3 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,457 Points

A key part of the instructions are: "...extend "layout.html" (which is in the "code_challenges" directory)."

This means you need to include the path to the "layout.html" file:

{% extends "code_challenges/layout.html" %}
Sergey Shyshka
Sergey Shyshka
8,990 Points

Thank you very much for the explanations Chris.

Sergey Shyshka
Sergey Shyshka
8,990 Points

Hi Chris,

Thanks for the detailed response, now everything works fine. But I have one more question on this: Why does my code run localy without the part of the path to the file? Is the reason in the TEMPLATES [ {'DIRS': ['templates', ]},] of my project settings file, or I am wrong?

Thanks.

Chris Freeman
Chris Freeman
Treehouse Moderator 68,457 Points

if, in your local environment, layout.html is in the templates directory, then you are correct. It is finding it locally due to the TEMPLATES value in the settings.py file.

I loaded one of the workspaces for the course. It has the same TEMPLATES value as you. The difference being that the challenge does not have the layout.html located in the top-level templates directory. So it won't be found without the path.