O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

21.6.1 Mixins for Sending and Logging Emails

The goal of our ActivationMailFormMixin is to send an account activation email to a new user. To that end, we must provide the string for an error in the form in the event the email is not sent. In Example 21.31, we create a mail_validation_error attribute for subclasses of the mixin to override, allowing developers to specify the output of the error in their own class.

Example 21.31: Project Code

user/utils.py in 0cbcf42d4f

23   class ActivationMailFormMixin: 24       mail_validation_error = ''

While we use parts of the form’s validation system to inform Django whether email was sent or not, we also want to be able to check this on the go. We therefore create a mail_sent ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required