From aae69f930b98453a2ea2eb8a517d2099ee40f1f7 Mon Sep 17 00:00:00 2001 From: JasonHomeWorkstationUbuntu Date: Tue, 20 Oct 2020 16:37:38 +1100 Subject: [PATCH] 3.4 Remove hardlink URL in template --- first_django_app.md | 18 +++++++++++++++++- src/polls/templates/polls/index.html | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/first_django_app.md b/first_django_app.md index 08a5f1e..c7cc962 100644 --- a/first_django_app.md +++ b/first_django_app.md @@ -223,4 +223,20 @@ Here `path()` function is passed **route** and **view**; two additional option a ``` -模板系统统一使用点符号来访问变量的属性 \ No newline at end of file +模板系统统一使用点符号来访问变量的属性 + +### 3.5 Remove hardlink URL in template + +In template `polls/index.html`, links are hardcoded as shown + +```html + {% for question in latest_question_list %} +
  • {{ question.question_text }}
  • + {% endfor %} +``` + +Consider `index.html` will be reused numerous times, 去耦合is necessary. + +```html +
  • {{ question.question_text }}
  • +``` \ No newline at end of file diff --git a/src/polls/templates/polls/index.html b/src/polls/templates/polls/index.html index 79823ba..0d002dd 100644 --- a/src/polls/templates/polls/index.html +++ b/src/polls/templates/polls/index.html @@ -1,7 +1,7 @@ {% if latest_question_list %} {% else %}