Luke Ryan Jernejcic

Sending HTML Emails In Django-Registration

July 12, 2010

I have been working on a project that uses django-registration for registering our users. This allows us to make sure that they have given a valid email address, and to some extent helps to prevent bots on the system.

One of the things that we want to do is make things easy for our users, but the checked out version of django-registration only sends text emails which requires the user to manually copy and paste the registration link in their browser. Not very user friendly for users that are not as well versed in computers or mobile platforms. So I went about fixing this myself.

To do this, I found an article at StackOverflow. Essentially the answer is just to follow the standard Django method of attaching an HTML version to the text version of the email. The StackOverflow question just confirmed that there was no way to do this without modifying the source for django-registration, which is not ideal, but oh well.

So do this, modify models.py function send_activation_email:

Thank you for registering with {{ site }}.

Go to [ http://{{ site.domain }}{% url registration\_activate activation\_key %} ](http://%7B%7B%20site.domain%20%7D%7D%7B%%20url%20registration_activate%20activation_key%20%%7D) activate your account.

Your account will expire in {{ expiration\_days }} days unless you activate it.

Written by Luke Ryan Jernejcic who lives and works in Austin Texas building useful things. Follow him on Twitter