[Answered ]-Django – context_processors

2πŸ‘

The culprit is the send_mail method of the PasswordResetForm class. Here, render_to_string is used to build the email body:

class PasswordResetForm(forms.Form):
    def send_mail(self, ...):
        # ...
        body = loader.render_to_string(email_template_name, context)
        # ...

If you want this to pass through your context processors, you need to use a custom subclass of PasswordResetForm where you you override the send_mail method and provide render_to_string with an additional keyword argument context_instance which must be a RequestContext instance:

        body = loader.render_to_string(
            email_template_name, context,
            context_instance=RequestContext(request)
        ) 
        # you might have to pass the request from the view 
        # to form.save() where send_mail is called

This holds for all template rendering. Only RequestContext instances pass through context processors.

πŸ‘€user2390182

Leave a comment