jfallstrom
jfallstrom

Reputation: 13

Django extends template tag is written out as text not parsed

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

Answers (3)

Shatish Desai
Shatish Desai

Reputation: 605

First read Doc

{% extends ''accounts/main.html' %} - you miss (%-sign)

Upvotes: 0

Jay Kahlon
Jay Kahlon

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

Aayush Agrawal
Aayush Agrawal

Reputation: 1394

You are missing a % at the end

{% extends 'accounts/main.html' %}
{% block  content %}
<h1>Dashboard</h1>
{% endblock %}

Upvotes: 0

Related Questions