diff --git a/lostplaces/lostplaces_app/views.py b/lostplaces/lostplaces_app/views.py index af042f6..125a969 100644 --- a/lostplaces/lostplaces_app/views.py +++ b/lostplaces/lostplaces_app/views.py @@ -5,6 +5,7 @@ from django.shortcuts import render, redirect, get_object_or_404 from django.urls import reverse_lazy from django.views.generic.edit import CreateView, UpdateView, DeleteView +from django.views.generic import ListView from django.views import View from django.http import Http404 from django.contrib import messages @@ -48,12 +49,10 @@ class SignUpView(SuccessMessageMixin, CreateView): template_name = 'signup.html' success_message = 'User created.' -class PlaceListView(IsAuthenticated, View): - def get(self, request): - context = { - 'place_list': Place.objects.all() - } - return render(request, 'place/place_list.html', context) +class PlaceListView(IsAuthenticated, ListView): + paginate_by = 5 + model = Place + template_name = 'place/place_list.html' class PlaceDetailView(IsAuthenticated, View): def get(self, request, pk):