Build all_projects view

This commit is contained in:
David Doblas Jiménez 2022-01-04 15:38:54 +01:00
parent 77a2e7d954
commit edaa41811f
2 changed files with 8 additions and 0 deletions

View File

@ -2,5 +2,6 @@ from django.urls import path
from projects import views
urlpatterns = [
path("", views.all_projects),
path("test", views.project_list),
]

View File

@ -1,5 +1,12 @@
from django.shortcuts import render
from projects.models import Project
# Create your views here.
def project_list(request):
return render(request, "projects/index.html")
def all_projects(request):
# query the db to return all project objects
projects = Project.objects.all()
return render(request, "all_projects.html", {"projects": projects})