user3108063
user3108063

Reputation: 85

django template extends does not work

I don't know what I got wrong, but I cannot get template extension working.

What I want to do:

Say, the page will look like this (click me to see the screenshot). The yellow area is where is customisable.

I created 2 .html pages. 1 is the base (accountbase.html), 1 is the extended (accountregister.html).

accountbase.html (right click open to see screenshot) Remember to click on 100%.

.

. The yellow area in the base html (id="custom_content") is what to be extended (replaced).

My accountregister.html page is like this:

{%extends "accountbase.html" %}

{% block custom_content %}


<h2>account register page.</h2>


{% endblock %}

And I have checked that my view is wired to the correct html page:

def register(request):
    return render_to_response('accountregister.html')

. But http:// 1 2 7.0.0.1:8000/account/register/ only displays the base template. What could be wrong????

Many thanks for any suggestion.!

Upvotes: 2

Views: 713

Answers (1)

Simeon Visser
Simeon Visser

Reputation: 122376

Do you have a {% block custom_content %} in accountbase.html? Otherwise it won't work.

So the base template should have:

{% block custom_content %}{% endblock %}

and accountregister.html should have your content:

{% block custom_content %}

<h2>account register page.</h2>

{% endblock %}

Upvotes: 2

Related Questions