From 694543d088fe8dcac135e81e5c01667a8c99265d Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Sun, 26 Jul 2020 23:25:07 +0200 Subject: [PATCH] Added places list view. --- source/lostplaces/lostplaces_app/urls.py | 5 +++-- source/lostplaces/lostplaces_app/views.py | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/source/lostplaces/lostplaces_app/urls.py b/source/lostplaces/lostplaces_app/urls.py index 961e7e9..563e53a 100644 --- a/source/lostplaces/lostplaces_app/urls.py +++ b/source/lostplaces/lostplaces_app/urls.py @@ -1,7 +1,8 @@ from django.urls import path -from .views import hello_world, place_detail_view +from .views import hello_world, place_detail_view, place_list_view urlpatterns = [ path('hello_world/', hello_world), - path('place//', place_detail_view) + path('place//', place_detail_view), + path('places/', place_list_view) ] \ No newline at end of file diff --git a/source/lostplaces/lostplaces_app/views.py b/source/lostplaces/lostplaces_app/views.py index e27735c..07a4b08 100644 --- a/source/lostplaces/lostplaces_app/views.py +++ b/source/lostplaces/lostplaces_app/views.py @@ -3,9 +3,11 @@ from .models import Place # Create your views here. +def place_list_view(request,): + return render(request, 'placeList.html', {'place':Place.objects.all()}) + def place_detail_view(request, pk): - return render(request, 'placeOverview.html', {'place':Place.objects.get(pk=pk) -}) + return render(request, 'placeOverview.html', {'place':Place.objects.get(pk=pk)}) def hello_world(request): return render(request, 'hello_world.html', {'text':'Hello World!'})