Add account deletion functionality with confirmation dialog and routing
This commit is contained in:
parent
cd0ca2f5ea
commit
8faff47696
6 changed files with 46 additions and 13 deletions
|
@ -4,7 +4,7 @@ from django.contrib.messages.views import SuccessMessageMixin
|
|||
from django.shortcuts import redirect
|
||||
from django.urls import reverse_lazy
|
||||
from django.views.generic.base import TemplateView
|
||||
from django.views.generic.edit import CreateView, UpdateView
|
||||
from django.views.generic.edit import CreateView, DeleteView, UpdateView
|
||||
|
||||
from . import forms
|
||||
|
||||
|
@ -52,3 +52,13 @@ class AccountView(UpdateView):
|
|||
if queryset is None:
|
||||
queryset = self.get_queryset()
|
||||
return queryset.get(pk=self.request.user.pk)
|
||||
|
||||
|
||||
class AccountDeleteView(DeleteView):
|
||||
model = User
|
||||
success_url = reverse_lazy("index")
|
||||
|
||||
def get_object(self, queryset=None):
|
||||
if queryset is None:
|
||||
queryset = self.get_queryset()
|
||||
return queryset.get(pk=self.request.user.pk)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue