Hi Malcolm,

On 20 Jan 2009, at 02:33, Malcolm Tredinnick wrote:

>
> On Tue, 2009-01-20 at 02:07 +0000, Hans Fangohr wrote:
> [...]
>> However, in the template files, I extend my base.html which makes use
>> of the request object (basically checking whether the request has as
>> authenticated used and changing the html depending on this).
>>
>> It appears that the request object is not available in registration/
>> password_change_form.html when called from the view
>> django.contrib.auth.views.password_change.
>
> You might well be approachign this the wrong way. That particular view
> uses a RequestContext as the context instance passed to the template.
> Which means, unless you have changed the default context processors,  
> you
> will have a "user" variable in the context, representing the current
> user. That's the common approach to accessing things like the required
> user.
Aha! I was (foolishly) using request.user for this.

>
>
> Refer to http://docs.djangoproject.com/en/dev/ref/templates/api/#id1  
> for
> details.
Thank you.

>
>
> If, for some reason, you really, really, really need the full request
> object to be available there and, for some reason, writing your own
> version of the view isn't an option (it's less than 12 lines long;
> maintaining your own version won't be too onerous), you could write  
> your
> own context processor that included the full "request" instance in the
> context. The simplest approach, though, would be to switch to using
> "user", rather than "request" as the thing you check.

No, you are right. Have switched to RequestContext(request), i.e.  
using 'user' instead of 'request.user' within the base template, and  
all is well now.

Very useful feedback -- many thanks,

Hans


>
>
> Regards,
> Malcolm
>
>>
>> Here is the question: Is there a (simple?) way of feeding that  
>> request
>> object somehow into the view so that it can be used in the
>> registration/password_change_form.html?
>>
>> Many thanks for any hints in advance,
>>
>> Hans
>>
>>
>>
>>
>>
>>
>>
>>>
>>
>
>
> >
>
>


--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to