Opened 4 years ago

Closed 2 years ago

Last modified 21 months ago

#16319 closed New feature (fixed)

add success_message in ClassViews

Reported by: wilsonpjunior@… Owned by: paulcollins
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 aaugustin)

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 4 years ago.
Add SuccessMessageMixin to django.contrib.messages.views
ticket_16319.patch (5.8 KB) - added by d1ffuz0r 2 years ago.

Download all attachments as: .zip

Change History (20)

comment:1 Changed 4 years ago by aaugustin

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

Just reformatted code excerpt.

comment:2 Changed 4 years ago by lrekucki

  • Component changed from Generic views to contrib.messages
  • Easy pickings set
  • Triage Stage changed from Unreviewed to Accepted

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

  • Owner changed from nobody to martinogden
  • Status changed from new to assigned

Changed 4 years ago by martinogden

Add SuccessMessageMixin to django.contrib.messages.views

comment:4 Changed 4 years ago by martinogden

  • Has patch set

comment:5 Changed 4 years ago by ptone

  • 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 4 years ago by jacob

  • milestone 1.4 deleted

Milestone 1.4 deleted

Changed 2 years ago by d1ffuz0r

comment:7 Changed 2 years ago by d1ffuz0r

  • Easy pickings unset
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Version changed from 1.3 to master

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

comment:8 Changed 2 years ago by d1ffuz0r

  • Cc d1fffuz0r@… added

comment:9 Changed 2 years ago by paulcollins

  • Owner changed from martinogden to paulcollins
  • Patch needs improvement set

Grabbing this one and updating for the current master.

comment:10 Changed 2 years ago by paulcollins

  • Patch needs improvement unset

comment:11 Changed 2 years ago by charettes

#17818 was a duplicate.

comment:12 Changed 2 years ago by Carny Cheng

  • Triage Stage changed from Accepted to Ready for checkin

Pull request looks good. Tests run.

comment:13 follow-up: Changed 2 years ago by claudep

  • Patch needs improvement set
  • Triage Stage changed from Ready for checkin to Accepted

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 2 years ago by paulcollins

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 2 years ago by paulcollins

  • Patch needs improvement unset
  • Triage Stage changed from Accepted to Ready 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 2 years ago by Preston Holmes <preston@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In 9a85ad89c20e88340cdba85b8e9f5806c95835db:

Fixed #16319 -- added SuccessMessageMixin to contrib.messages

Thanks martinogden for the initial patch and d1ffuz0r for tests.

comment:17 Changed 23 months 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 21 months 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