Add the tasks to be shown on the index page.
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
+7
-1
@@ -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)
|
||||
|
||||
|
||||
@@ -3,4 +3,19 @@
|
||||
|
||||
{% block content %}
|
||||
<center><h1>Tasks</h1></center>
|
||||
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<td>Status</td>
|
||||
<td>Name</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
{% for task in tasks %}
|
||||
<tr>
|
||||
<td>{{ task.status }}</td>
|
||||
<td>{{ task.name }}</td>
|
||||
<td>{{ task.description | truncatewords:10 }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user