Re: request and email templates
On Dec 13, 5:06 pm, Tim Miller <t...@lashni.net> wrote:
> I'm using django.contrib.auth.views.password_reset and trying to pass
> the ip address of the user requesting a password reset into the
> confirmation email.
>
> I've enabled django.core.context_processors.request in settings and can
> successfully display request.META.REMOTE_ADDR in the form.html template
> but can't seem to access request at all within the email template.
>
> From what I've been reading and trying, I don't believe I can directly
> pass a context to this generic view so I'm wondering if there's
> something simple I'm missing or if I need to abandon the shortcuts and
> just write my own custom view.
>
> urls.py snipped:
>
> urlpatterns = patterns('django.contrib.auth',
>
> (r'^reset/$', 'views.password_reset', {
> 'template_name': 'users/reset/form.html',
> 'email_template_name': 'users/reset/email.html',
> 'post_reset_redirect': 'done/',
>
> }),
>
> )
>
> Tim.
Looking at the code for that view, in
django.contrib.auth.views.password_reset, it appears that the actual
email creation and sending happens in the save method of the
PasswordResetForm, and the request is not passed into that method at
all so is not available in the template.
To make this work, you'd have to override both the view and the form.
It's not an unreasonable thing to want to do though - if you're keen,
raise a ticket with a patch.
--
DR.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home