|
@@ -1,5 +1,3 @@
|
|
|
-import warnings
|
|
|
-
|
|
|
from django.core.exceptions import ImproperlyConfigured
|
|
|
from django.forms import Form
|
|
|
from django.forms import models as model_forms
|
|
@@ -240,11 +238,6 @@ class DeletionMixin:
|
|
|
raise ImproperlyConfigured("No URL to redirect to. Provide a success_url.")
|
|
|
|
|
|
|
|
|
-# RemovedInDjango50Warning.
|
|
|
-class DeleteViewCustomDeleteWarning(Warning):
|
|
|
- pass
|
|
|
-
|
|
|
-
|
|
|
class BaseDeleteView(DeletionMixin, FormMixin, BaseDetailView):
|
|
|
"""
|
|
|
Base view for deleting an object.
|
|
@@ -254,19 +247,6 @@ class BaseDeleteView(DeletionMixin, FormMixin, BaseDetailView):
|
|
|
|
|
|
form_class = Form
|
|
|
|
|
|
- def __init__(self, *args, **kwargs):
|
|
|
- # RemovedInDjango50Warning.
|
|
|
- if self.__class__.delete is not DeletionMixin.delete:
|
|
|
- warnings.warn(
|
|
|
- f"DeleteView uses FormMixin to handle POST requests. As a "
|
|
|
- f"consequence, any custom deletion logic in "
|
|
|
- f"{self.__class__.__name__}.delete() handler should be moved "
|
|
|
- f"to form_valid().",
|
|
|
- DeleteViewCustomDeleteWarning,
|
|
|
- stacklevel=2,
|
|
|
- )
|
|
|
- super().__init__(*args, **kwargs)
|
|
|
-
|
|
|
def post(self, request, *args, **kwargs):
|
|
|
# Set self.object before the usual form processing flow.
|
|
|
# Inlined because having DeletionMixin as the first base, for
|