{{{
#!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)
~
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22752>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Correction, PasswordResetForm does not have current_app built in. That
needs to be added as well.
--
Ticket URL: <https://code.djangoproject.com/ticket/22752#comment:1>
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Correction, PasswordResetForm does not have current_app built in. That
needs to be added as well.
--
Ticket URL: <https://code.djangoproject.com/ticket/22752#comment:2>
* needs_better_patch: => 0
* needs_tests: => 0
* easy: 1 => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/22752#comment:2>
* needs_better_patch: 0 => 1
* needs_tests: 0 => 1
* needs_docs: 0 => 1
* has_patch: 0 => 1
* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
Hi,
I agree that it would be good to have the current app while rendering the
body of the email because it would help with reversing URLs inside it.
However, I don't really understand the use-case behind having the current
app when rendering the subject line.
In any case, the provided patch doesn't apply on master and it's also
going to require tests and documentation.
Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/22752#comment:3>
Comment (by bendavis78):
@bmispelon, I think one would expect the context to be identical in both
the body and the subject. Whether or not there's a use case, I can't think
of any justification for making them separate. I plan on working on this
(as well as various other tickets I've submitted) once I get a little more
free time.
--
Ticket URL: <https://code.djangoproject.com/ticket/22752#comment:4>
* cc: bendavis78 (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/22752#comment:5>
* owner: nobody => Hasan Ramezani
* status: new => assigned
Comment:
@felixxm Do we still need this ticket?
--
Ticket URL: <https://code.djangoproject.com/ticket/22752#comment:6>
* needs_better_patch: 1 => 0
* has_patch: 1 => 0
* needs_tests: 1 => 0
* needs_docs: 1 => 0
Comment:
`current_app` is no longer an argument to `render_to_string()` but I think
this would be resolved by passing `request` instead (which can be passed
to `send_mail()` from `save()`). The `url` template tag uses the namespace
of the currently resolved view as the current application in a
`RequestContext`.
--
Ticket URL: <https://code.djangoproject.com/ticket/22752#comment:7>