diff --git a/lostplaces/lostplaces_app/views.py b/lostplaces/lostplaces_app/views.py index 3f20e5c..d364f9a 100644 --- a/lostplaces/lostplaces_app/views.py +++ b/lostplaces/lostplaces_app/views.py @@ -70,14 +70,13 @@ class HomeView(View): } return render(request, 'home.html', context) -class PlaceUpdateView(IsAuthenticated, IsSubmitter, UpdateView): +class PlaceUpdateView(IsAuthenticated, IsSubmitter, SuccessMessageMixin, UpdateView): template_name = 'place/place_update.html' model = Place form_class = PlaceForm + success_message = 'Successfully updated place.' def get_success_url(self): - messages.success( - self.request, 'Successfully updated place.') return reverse_lazy('place_detail', kwargs={'pk':self.get_object().pk}) class PlaceCreateView(IsAuthenticated, View): @@ -136,8 +135,9 @@ class PlaceCreateView(IsAuthenticated, View): ) place_image.save() -class PlaceDeleteView(IsAuthenticated, IsSubmitter, DeleteView): +class PlaceDeleteView(IsAuthenticated, IsSubmitter, SuccessMessageMixin, DeleteView): template_name = 'place/place_delete.html' model = Place success_url = reverse_lazy('place_list') + success_message = 'Successfully deleted place.' \ No newline at end of file