mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #21936 -- Allowed DeleteView to work with custom Forms and SuccessMessageMixin.
Thanks to Mariusz Felisiak for review. Co-authored-by: Demetris Stavrou <demestav@gmail.com> Co-authored-by: Caroline Simpson <github@hoojiboo.com>
This commit is contained in:
parent
37e8367c35
commit
3a45fea083
10 changed files with 122 additions and 8 deletions
|
@ -6,7 +6,9 @@ from django.template import engines
|
|||
from django.template.response import TemplateResponse
|
||||
from django.urls import path, re_path, reverse
|
||||
from django.views.decorators.cache import never_cache
|
||||
from django.views.generic.edit import FormView
|
||||
from django.views.generic.edit import DeleteView, FormView
|
||||
|
||||
from .models import SomeObject
|
||||
|
||||
TEMPLATE = """{% if messages %}
|
||||
<ul class="messages">
|
||||
|
@ -63,9 +65,16 @@ class ContactFormViewWithMsg(SuccessMessageMixin, FormView):
|
|||
success_message = "%(name)s was created successfully"
|
||||
|
||||
|
||||
class DeleteFormViewWithMsg(SuccessMessageMixin, DeleteView):
|
||||
model = SomeObject
|
||||
success_url = '/show/'
|
||||
success_message = 'Object was deleted successfully'
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
re_path('^add/(debug|info|success|warning|error)/$', add, name='add_message'),
|
||||
path('add/msg/', ContactFormViewWithMsg.as_view(), name='add_success_msg'),
|
||||
path('delete/msg/<int:pk>', DeleteFormViewWithMsg.as_view(), name='success_msg_on_delete'),
|
||||
path('show/', show, name='show_message'),
|
||||
re_path(
|
||||
'^template_response/add/(debug|info|success|warning|error)/$',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue