From 7797387d917c7a8e6d87cddf40182783b9ea285c Mon Sep 17 00:00:00 2001 From: KKlochko Date: Wed, 12 Jul 2023 20:43:53 +0300 Subject: [PATCH] Add the tasks to be shown on the index page. --- CHANGELOG.org | 2 ++ tasks/views.py | 8 +++++++- templates/tasks/index.html | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.org b/CHANGELOG.org index 0d48f4c..8330f7f 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -3,4 +3,6 @@ Init project. ** 0.2.0 <2023-07-12 Wed> Add simple tasks app. +** 0.2.1 <2023-07-12 Wed> + Add the tasks to be shown on the index page. diff --git a/tasks/views.py b/tasks/views.py index c976fd7..41ee6cd 100644 --- a/tasks/views.py +++ b/tasks/views.py @@ -1,6 +1,12 @@ from django.shortcuts import render +from .models import Task def index(request): - context = {} + tasks = Task.objects.all() + + context = { + 'tasks': tasks, + } + return render(request, 'tasks/index.html', context) diff --git a/templates/tasks/index.html b/templates/tasks/index.html index 36c7e54..db2565a 100644 --- a/templates/tasks/index.html +++ b/templates/tasks/index.html @@ -3,4 +3,19 @@ {% block content %}

Tasks

+ + + + + + + + {% for task in tasks %} + + + + + + {% endfor %} +
StatusNameDescription
{{ task.status }}{{ task.name }}{{ task.description | truncatewords:10 }}
{% endblock %}