twoscoops / two-scoops-of-django-1.11

The issue tracker, changelog, and code repository for Two Scoops of Django 1.11

Home Page:https://www.twoscoopspress.com/products/two-scoops-of-django-1-11

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use Django SuccessMessageMixin instead of writing your own one

dorianamouroux opened this issue · comments

Location within the Book

  • Chapter or Appendix: 10 Best Practices for Class-Based Views
  • Section: 5
  • Subsection: 1

Description

In the exemple 10.9, you create a @property success_msg and overwrite the form_valid method, so when the form is valid, the success_msg is pushed to the Django messages. This Mixin already exist in the contrib.messages app. Link to the documentation.

Yeah, that was added thanks to an earlier edition of the book (1.5 or 1.6, I can't remember). However, the simplicity of the example is enough that we aren't going to change our example.

Maybe in the next edition, we'll put in a note explaining it.