Adjusted delete view

This commit is contained in:
reverend 2020-08-10 19:54:17 +02:00
parent 121b99730d
commit 675cdc5721

View File

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