Opened 13 years ago

Closed 11 years ago

Last modified 11 years ago

#16319 closed New feature (fixed)

add success_message in ClassViews

Reported by: wilsonpjunior@… Owned by: Paul Collins
Component: contrib.messages Version: dev
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 13 years ago.
Add SuccessMessageMixin to django.contrib.messages.views
ticket_16319.patch (5.8 KB ) - added by Roman Gladkov 11 years ago.

Download all attachments as: .zip

Change History (20)

comment:1 by Aymeric Augustin, 13 years ago

Description: modified (diff)

Just reformatted code excerpt.

comment:2 by Łukasz Rekucki, 13 years ago

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 by martinogden, 13 years ago

Owner: changed from nobody to martinogden
Status: newassigned

by martinogden, 13 years ago

Attachment: SuccessMessageMixin.diff added

Add SuccessMessageMixin to django.contrib.messages.views

comment:4 by martinogden, 13 years ago

Has patch: set

comment:5 by Preston Holmes, 13 years ago

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 by Jacob, 12 years ago

milestone: 1.4

Milestone 1.4 deleted

by Roman Gladkov, 11 years ago

Attachment: ticket_16319.patch added

comment:7 by Roman Gladkov, 11 years ago

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 by Roman Gladkov, 11 years ago

Cc: d1fffuz0r@… added

comment:9 by Paul Collins, 11 years ago

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

Grabbing this one and updating for the current master.

comment:10 by Paul Collins, 11 years ago

Patch needs improvement: unset

comment:11 by Simon Charette, 11 years ago

#17818 was a duplicate.

comment:12 by Carny Cheng, 11 years ago

Triage Stage: AcceptedReady for checkin

Pull request looks good. Tests run.

comment:13 by Claude Paroz, 11 years ago

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

in reply to:  13 comment:14 by Paul Collins, 11 years ago

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 by Paul Collins, 11 years ago

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 by Preston Holmes <preston@…>, 11 years ago

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 by Preston Holmes <preston@…>, 11 years ago

In b1bfd9630ef049070b0cd6ae215470d3d1facd40:

Remove unnecessary and problematic parent class from SuccessMessageMixin

refs #16319, thanks to bmispelon for the catch

comment:18 by anonymous, 11 years ago

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