Skip to content

Instantly share code, notes, and snippets.

@aliceridgway
Created October 23, 2021 15:27
Show Gist options
  • Save aliceridgway/da54ef0844e6ed87ebce7f196066db66 to your computer and use it in GitHub Desktop.
Save aliceridgway/da54ef0844e6ed87ebce7f196066db66 to your computer and use it in GitHub Desktop.
Django Todo App - views.py - list todos
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