Created
October 23, 2021 15:27
-
-
Save aliceridgway/da54ef0844e6ed87ebce7f196066db66 to your computer and use it in GitHub Desktop.
Django Todo App - views.py - list todos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render | |
from .models import Todo | |
# Create your views here. | |
def list_todos(request): | |
""" Displays a list of posts """ | |
todos = Todo.objects.filter(completed=False).order_by('-created_on') | |
context = { | |
'page_title': 'To Do List', | |
'todos': todos | |
} | |
return render(request, 'index.html', context) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment