From 675cdc57216bbd9c68780123b00b76e57ac78862 Mon Sep 17 00:00:00 2001 From: reverend Date: Mon, 10 Aug 2020 19:54:17 +0200 Subject: [PATCH] Adjusted delete view --- lostplaces/lostplaces_app/views.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) 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')