Converted PlaceList into a ListView and added pagination.

This commit is contained in:
Marcus Scholz 2020-08-12 21:53:49 +02:00
parent c148cc5f10
commit 1a70c1437e

View File

@ -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):