﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
22752	Allow PasswordResetForm email to render URLs based on the current namespace	Ben Davis	nobody	"I have multiple namespace instances for password reset urls. The email template rendered by the default PasswordResetForm does not included a `current_app` context. It's an easy fix, though, ass the PasswordResetForm already has `self.current_app`. Just need to wrap the context instance passed to the email template:

{{{
#!diff
diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
index 6e07d45..baef873 100644
--- a/django/contrib/auth/forms.py
+++ b/django/contrib/auth/forms.py
@@ -4,7 +4,7 @@ from collections import OrderedDict

 from django import forms
 from django.forms.utils import flatatt
-from django.template import loader
+from django.template import loader, Context
 from django.utils.encoding import force_bytes
 from django.utils.html import format_html, format_html_join
 from django.utils.http import urlsafe_base64_encode
@@ -264,10 +264,13 @@ class PasswordResetForm(forms.Form):
                 'token': token_generator.make_token(user),
                 'protocol': 'https' if use_https else 'http',
             }
-            subject = loader.render_to_string(subject_template_name, c)
+            context_instance = Context(current_app=self.current_app)
+            subject = loader.render_to_string(
+                subject_template_name, c, context_instance)
             # Email subject *must not* contain newlines
             subject = ''.join(subject.splitlines())
-            email = loader.render_to_string(email_template_name, c)
+            email = loader.render_to_string(
+                email_template_name, c, context_instance)

             if html_email_template_name:
                 html_email = loader.render_to_string(html_email_template_name, c)
~
}}}"	Cleanup/optimization	new	contrib.auth	dev	Normal			Ben Davis	Accepted	0	0	0	0	0	0
