【问题标题】:extends 'base.html' doesn't work in django扩展“base.html”在 django 中不起作用
【发布时间】:2020-11-15 09:24:57
【问题描述】:

我的 base.html 代码 -

<html>

<body bgcolor="cyan">

{% block content %}

{% endblock %}

</body>

</html>

我的 home.html 代码-

<% extends 'base.html' %>

<% block content %>

<h1>Hello {{name}}!!!</h1>

<% endblock %>

django 服务器输出

<% extends 'base.html' %> <% block content %>
Hello viraj!!!
<% endblock %>

home.html 和 base.html 在同一个目录中。

【问题讨论】:

  • 你假设&lt;% 对 Django 意味着什么,但它只对 ASP 意味着什么。使用{%
  • 哪个目录?是那些吗?

标签: django templates extends


【解决方案1】:

你使用花括号,而不是尖括号。

{% extends 'base.html' %}

{% block content %}

<h1>Hello {{name}}!!!</h1>

{% endblock %}

【讨论】:

    猜你喜欢
    • 2021-02-05
    • 2012-09-27
    • 1970-01-01
    • 1970-01-01
    • 2020-06-06
    • 1970-01-01
    • 2016-09-29
    • 1970-01-01
    • 2016-06-11
    相关资源
    最近更新 更多