如何在 django 中使用 jinja 与 {% url 'index' %} 链接?持续误差



添加 jinja 脚本后,我在第 0 行得到一个 TypeError

文件关于.html

{% extends 'base.html' %} {% load static %} {% block content %}
<section id="showcase-inner" class="py-5 text-white">
<div class="container">
<div class="row text-center">
<div class="col-md-12">
<h1 class="display-4">About BT Real Estate</h1>
<p class="lead">
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Sunt,
pariatur!
</p>
</div>
</div>
</div>
</section>
<!-- Breadcrumb -->
<section id="bc" class="mt-3">
<div class="container">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="**{% url 'index' %}**"> <i class="fas fa-home"></i> Home</a>
</li>
<li class="breadcrumb-item active">About</li>
</ol>
</nav>
</div>
</section>

模板呈现期间出错 在模板 C:\Users\Sam\Coding\Udemy\Python Django\btre_project\templates\base.html 中,第 0 行出错

"set"对象不可逆

{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Font Awesome -->
<link rel="stylesheet" href="{% static 'css/all.css' %}" />
<!-- Bootstrap -->
<link rel="stylesheet" href="{% static 'css/bootstrap.css' %}" />

BASE

.HTML
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Font Awesome -->
<link rel="stylesheet" href="{% static 'css/all.css' %}" />
<!-- Bootstrap -->
<link rel="stylesheet" href="{% static 'css/bootstrap.css' %}" />
{% block body %}{% endblock %}

这里我们必须在 base.html 文件中写入块体

关于

.HTML
{% load static %} {% extends '(appname)/base.html' %}{% block body %}
<section id="showcase-inner" class="py-5 text-white">
<div class="container">
<div class="row text-center">
<div class="col-md-12">
<h1 class="display-4">About BT Real Estate</h1>
<p class="lead">
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Sunt,
pariatur!
</p>
</div>
</div>
</div>
</section>
<!-- Breadcrumb -->
<section id="bc" class="mt-3">
<div class="container">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="**{% url 'index' %}**"> <i class="fas fa-home"></i> Home</a>
</li>
<li class="breadcrumb-item active">About</li>
</ol>
</nav>
</div>
</section>{%endblock%}

在大约中.html我们必须逐块指定块正文标签。

最新更新