Search code examples
djangodjango-registration

Adding/changing logic in send_email method within django-registration-redux


My site runs multiple domains. Users can register on each of these domains. As a result, I need to make django-registration-redux:

  • use the correct email address for sending registration/password reset emails

  • use the correct email password for sending registration/password reset emails

  • use the correct domain within registration/password reset emails

I've been digging into the source code for django-registration-redux and believe that I need to update the send_email method within registration/models.py (https://github.com/macropin/django-registration/blob/master/registration/models.py) with my required changes.

I'm assuming the best way to add this cusomtization is as follows:

  • run 'pip uninstall django-registration-redux==2.2'
  • run 'pip freeze > requirements.txt'

  • from the source code, pull the 'registration' folder into my project

  • go into myproject/registration/models.py and manually update the send_email method so that it includes my changes.

Is there an easier or more correct way to build my custom logic into def send_email without making the changes noted above?

Thanks!


Solution

  • Solution is to add a context processor that grabs the company name and website based on the current website, which can be accessed via request, and then reference the context variable within the django-registration email templates :)