Reputation: 13
I'm a beginner trying to learn Django by following tutorials. I am currently working on template inheritence.
When i try to extend a template.
{% extends 'accounts/main.html'}
{% block content %}
<h1>Dashboard</h1>
{% endblock %}
The file is not extended. Instead this is written as plain text {% extends 'accounts/main.html'} when i view the page.
The template i try to extend looks like this.
<!doctype html>
<html lang="sv">
<head>
<meta charset="utf-8">
<title>Base template</title>
<meta name="description" content="">
<meta name="author" content="">
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
I have searched for this problem but found no solution. Can you please help me?
Upvotes: 1
Views: 152
Reputation: 605
First read Doc
{% extends ''accounts/main.html' %} - you miss (%-sign)
Upvotes: 0
Reputation: 131
you are missing the closing %
in 1st line.
in my opinion, it's best practice to write the tag first and then enter elements 1 by 1 until you get comfortable with the syntax.
I would start out like this
{% %}
and then add
{%
extends
%}
and then
{% extends
'base.html'
%}
Best Wishes.
Happy Coding
Upvotes: 1
Reputation: 1394
You are missing a % at the end
{% extends 'accounts/main.html' %}
{% block content %}
<h1>Dashboard</h1>
{% endblock %}
Upvotes: 0