From 430167db83e7e0161b185f2ba4843209d933e6d0 Mon Sep 17 00:00:00 2001 From: JasonHomeWorkstationUbuntu Date: Wed, 11 Nov 2020 18:03:02 +1100 Subject: [PATCH] 8.3 Django Template Inheritance --- src/lists/templates/base.html | 15 +++++++++++++++ src/lists/templates/home.html | 17 +++++------------ src/lists/templates/list.html | 29 ++++++++++++----------------- 3 files changed, 32 insertions(+), 29 deletions(-) create mode 100644 src/lists/templates/base.html diff --git a/src/lists/templates/base.html b/src/lists/templates/base.html new file mode 100644 index 0000000..af8c192 --- /dev/null +++ b/src/lists/templates/base.html @@ -0,0 +1,15 @@ + + + To-Do lists + + + +

{% block header_text %}{% endblock %}

+
+ + {% csrf_token %} +
+ {% block table %} + {% endblock %} + + \ No newline at end of file diff --git a/src/lists/templates/home.html b/src/lists/templates/home.html index fef18f5..34ad36d 100644 --- a/src/lists/templates/home.html +++ b/src/lists/templates/home.html @@ -1,12 +1,5 @@ - - - To-Do lists - - -

Your To-Do list

-
- - {% csrf_token %} -
- - \ No newline at end of file +{% extends 'base.html' %} + +{% block header_text %}Start a new To-Do list{% endblock %} + +{% block form_action %}/lists/new{% endblock %} \ No newline at end of file diff --git a/src/lists/templates/list.html b/src/lists/templates/list.html index f27d3bb..361391e 100644 --- a/src/lists/templates/list.html +++ b/src/lists/templates/list.html @@ -1,18 +1,13 @@ - - - To-Do lists - - -

Your To-Do list

-
- - {% csrf_token %} -
+{% extends 'base.html' %} - - {% for item in list.item_set.all %} - - {% endfor %} -
{{ forloop.counter }}: {{ item.text }}
- - \ No newline at end of file +{% block header_text %}Your To-Do list{% endblock %} + +{% block form_action %}/lists/{{ list.id }}/add_item{% endblock %} + +{% block table %} + + {% for item in list.item_set.all %} + + {% endfor %} +
{{ forloop.counter }}: {{ item.text }}
+{% endblock %} \ No newline at end of file