-
-
Notifications
You must be signed in to change notification settings - Fork 516
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
The type-stubs for BaseDeleteView and DeleteView incorrectly require the form value to be a ModelForm, while Django documentation implies a plain Form should be enough.
What's wrong
The Django stubs for django.views.generic.edit state the following:
class BaseDeleteView(Generic[_M, _ModelFormT], DeletionMixin[_M], FormMixin[_ModelFormT], BaseDetailView[_M]):
class DeleteView(Generic[_M, _ModelFormT], SingleObjectTemplateResponseMixin, BaseDeleteView[_M, _ModelFormT]):
looking at the actual implementation however,
class BaseDeleteView(DeletionMixin, FormMixin, BaseDetailView):
...
form_class = Form
The Django documentation itself also states that the default form is the empty form: https://docs.djangoproject.com/en/5.2/ref/class-based-views/generic-editing/#django.views.generic.edit.DeleteView.form_class, suggesting that using a non-model-form is indeed acceptable behavior.
How is that should be
I think the stubs should read
class BaseDeleteView(Generic[_M, _FormT], DeletionMixin[_M], FormMixin[_FormT], BaseDetailView[_M]):
class DeleteView(Generic[_M, _FormT], SingleObjectTemplateResponseMixin, BaseDeleteView[_M, _FormT]):
System information
(I think all of the following are irrelevant, but just in case):
- OS: Debian Linux.
pythonversion: Python 3.13.6djangoversion: 5.2.5mypyversion: 1.17.1django-stubsversion: 5.2.2django-stubs-extversion: 5.2.2
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working