Opened 5 years ago

Closed 4 years ago

Last modified 3 years ago

#16319 closed New feature (fixed)

add success_message in ClassViews

Reported by: wilsonpjunior@… Owned by: Paul Collins
Component: contrib.messages Version: master
Severity: Normal Keywords:
Cc: d1fffuz0r@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Aymeric Augustin)

sample:

class CreatePersonView(CreateView):
    model = Person
    success_url = "/"
    success_message = "%(name)s was created successfully"

after object created calls messages.sucess_message

:-)

Attachments (2)

SuccessMessageMixin.diff (934 bytes) - added by martinogden 5 years ago.
Add SuccessMessageMixin to django.contrib.messages.views
ticket_16319.patch (5.8 KB) - added by Roman Gladkov 4 years ago.

Download all attachments as: .zip

Change History (20)

comment:1 Changed 5 years ago by Aymeric Augustin

Description: modified (diff)
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

Just reformatted code excerpt.

comment:2 Changed 5 years ago by Łukasz Rekucki

Component: Generic viewscontrib.messages
Easy pickings: set
Triage Stage: UnreviewedAccepted

It should be quite easy to create a Mixin that does that (and put it in contrib.messages). I wouldn't incorporate that into the @CreateView@, as CBVs should be independent from contrib apps.

comment:3 Changed 5 years ago by martinogden

Owner: changed from nobody to martinogden
Status: newassigned

Changed 5 years ago by martinogden

Attachment: SuccessMessageMixin.diff added

Add SuccessMessageMixin to django.contrib.messages.views

comment:4 Changed 5 years ago by martinogden

Has patch: set

comment:5 Changed 5 years ago by Preston Holmes

Needs documentation: set
Needs tests: set
Patch needs improvement: set

Not sure if every corner of django needs to provide mixins. This is a good snippet, but needs docs and tests.

comment:6 Changed 5 years ago by Jacob

milestone: 1.4

Milestone 1.4 deleted

Changed 4 years ago by Roman Gladkov

Attachment: ticket_16319.patch added

comment:7 Changed 4 years ago by Roman Gladkov

Easy pickings: unset
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Version: 1.3master

this patch was improved, added tests and documentation (need to improve, English language non native for me.)

comment:8 Changed 4 years ago by Roman Gladkov

Cc: d1fffuz0r@… added

comment:9 Changed 4 years ago by Paul Collins

Owner: changed from martinogden to Paul Collins
Patch needs improvement: set

Grabbing this one and updating for the current master.

comment:10 Changed 4 years ago by Paul Collins

Patch needs improvement: unset

comment:11 Changed 4 years ago by Simon Charette

#17818 was a duplicate.

comment:12 Changed 4 years ago by Carny Cheng

Triage Stage: AcceptedReady for checkin

Pull request looks good. Tests run.

comment:13 Changed 4 years ago by Claude Paroz

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

Unfortunately, the .format() does not work well with the gettext-based translation system. So for all translatable strings in Django, we should stick with the %(name)s placeholder style.
http://savannah.gnu.org/bugs/?30854

comment:14 in reply to:  13 Changed 4 years ago by Paul Collins

Replying to claudep:

Unfortunately, the .format() does not work well with the gettext-based translation system.

Oh? Didn't know that. Okay I'll update the patch and resubmit

comment:15 Changed 4 years ago by Paul Collins

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

PR updated. (https://github.com/django/django/pull/922)
Since the change was pretty straight forward and all tests are still passing I've bounced this back to Ready, but if that's not kosher please let me know.

comment:16 Changed 4 years ago by Preston Holmes <preston@…>

Resolution: fixed
Status: assignedclosed

In 9a85ad89c20e88340cdba85b8e9f5806c95835db:

Fixed #16319 -- added SuccessMessageMixin to contrib.messages

Thanks martinogden for the initial patch and d1ffuz0r for tests.

comment:17 Changed 3 years ago by Preston Holmes <preston@…>

In b1bfd9630ef049070b0cd6ae215470d3d1facd40:

Remove unnecessary and problematic parent class from SuccessMessageMixin

refs #16319, thanks to bmispelon for the catch

comment:18 Changed 3 years ago by anonymous

SuccessMessageMixin is useful for django.views.generic.edit.DeleteView but it should be implemented as mixin.

Note: See TracTickets for help on using tickets.
Back to Top