Search code examples
djangodjango-modelsdjango-registration

override the send activation mail in django-registration


I want to override the send_activation_email in django-registration app in order to be able to send mail with html content instead of just text. Note that this function is defined in the models of the RegistrationManager model.

Thanks a lot in advance.


Solution

  • Use custom model, example:

    from registration.models import RegistrationProfile
    
    
    class CustomRegistrationProfile(RegistrationProfile):
        """
        Custom registration profile
        """
    
        class Meta:
            proxy = True
    
        def send_activation_email(self, site):
            """
            Override method for custom send email
            """
    

    Or, such a method override:

    from registration.models import RegistrationProfile
    
    def send_activation_email(self, site):
        """
        Override method for custom send email
        """
    
    RegistrationProfile.send_activation_email = send_activation_email