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 ...

Get Django Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.