diff --git a/lostplaces/lostplaces_app/views.py b/lostplaces/lostplaces_app/views.py index bf17980..d49bc9e 100644 --- a/lostplaces/lostplaces_app/views.py +++ b/lostplaces/lostplaces_app/views.py @@ -4,7 +4,7 @@ ''' Django views. ''' from django.shortcuts import render, redirect, get_object_or_404 from django.urls import reverse_lazy -from django.views.generic.edit import CreateView, UpdateView +from django.views.generic.edit import CreateView, UpdateView, DeleteView from django.views import View from django.http import Http404 @@ -96,14 +96,10 @@ class PlaceCreateView(View): ) place_image.save() -class PlaceDeleteView(View): - #template_name = 'delete_place.html' - #model = Place - #form_class = PlaceDeleteForm +class PlaceDeleteView(DeleteView): + template_name = 'delete_place.html' + model = Place + form_class = PlaceDeleteForm - def get(self, request, pk, *args, **kwargs): - place = Place.objects.get(pk=pk) - place_delete_form = PlaceDeleteForm() - - context = {'place': place, 'form': place_delete_form} - return render(request, 'delete_place.html', context) + def get_success_url(self): + return reverse_lazy('place_list')