Hiya L,
Your are welcome!

It is not obvious from the tutorial, but RequestContext as its name 
suggests also passes the request context to the template. The 
context_instance uses the auth middleware context processor and provides 
the user in the view. You could also refer to `{{ request.user }}` in the 
template, but I wouldn't recommend it. RequestContext automatically 
populates everything for you with nice variable names.

Cheers,
Hevok



On Friday, September 21, 2012 12:50:13 AM UTC+2, Lachlan Musicman wrote:
>
> On Fri, Sep 21, 2012 at 10:29 AM, hevok <d.a.w...@gmail.com <javascript:>> 
> wrote: 
> > Hola Lachlan, 
> > Are you passing the `context_instance=RequestContext(request)` to all 
> > templates? It should provide the user tag. 
>
> Hi Hevok, 
>
> Thanks for the reply. 
>
> I did attempt to merely pass the request: 
>
> @login_required 
> def index(request): 
>     """ 
>     If users are authenticated, direct them to the main page. 
> Otherwise take them to the login page. 
>     """ 
>     daily_sessions = [] 
>
>     for session in range(4): 
>         daily_sessions.append([]) 
>         daily_sessions[session] = 
> Session.objects.filter(date=today).filter(session_number=session) 
>
>     return 
> render_to_response('tafe/timetable_today_detail.html',{'daily_sessions':daily_sessions,
>  
>
> 'request':request}) 
>
> but that didn't work. 
>
> I pass the RequestContext(request) for the forms I wrote to satisfy 
> CSRF stuff - I guess I just add something similar? 
>
> ...OK, I just added exactly the same as for the CSRF and it worked - 
> thanks Hevok! 
>
> cheers 
> L. 
>
>
>
> > 
> > Bests, 
> > Hevok 
> > 
> > 
> > On Friday, September 21, 2012 12:20:04 AM UTC+2, Lachlan Musicman wrote: 
> >> 
> >> Hola, 
> >> 
> >> I've noticed for a while that my home/index page wasn't registering 
> >> the {{ user }} tag when rendering the page: there was no "Welcome 
> >> Username. Change password / Log out" in the top right corner, and the 
> >> link to the admin interface that I'd put in the breadcrumbs for logged 
> >> in users wouldn't appear. 
> >> 
> >> But that was the only page - every other page showed it fine - so I 
> >> wasn't too concerned, and gave it a low priority to fix it. 
> >> 
> >> FWIW the whole site requires authentication (checked and confirmed in 
> >> another browser) - so Django knew I was auth'd - it just chose to 
> >> ignore some of the base.html 
> >> 
> >> Yesterday I added some thematic changes - a little js and css, plonked 
> >> it in path/project/app/static/{js|css} as advised in docs and added 
> >> them to the base template with {{ STATIC_URL }}. 
> >> 
> >> Suddenly the lack of auth recognition on some pages (turns out it was 
> >> more than one) is noticeable, because the graceful degrading of the 
> >> js/css is appalling enough to make it stick out. In particular, when I 
> >> "inspected element" I saw that the {{ STATIC_URL }} wasn't being 
> >> expanded - the resources were failing on bad paths. 
> >> 
> >> I've tracked everything down that could be the problem - I've 
> >> confirmed half a dozen times that the pages in question are extending 
> >> the correct base_site.html, which is extending the correct base.html, 
> >> I even tried sending the request context in render_to_response with no 
> >> luck. 
> >> 
> >> It was only this morning while doing some triage that I realised that 
> >> the pages without proper auth (no details in top right corner) where 
> >> also the ones with the wonky templating. 
> >> 
> >> Any clues on what I'm doing wrong or new ways to track down where the 
> >> mistake is? 
> >> 
> >> Cheers 
> >> L. 
> >> 
> >> 
> >> 
> >> -- 
> >> ...we look at the present day through a rear-view mirror. This is 
> >> something Marshall McLuhan said back in the Sixties, when the world 
> >> was in the grip of authentic-seeming future narratives. He said, “We 
> >> look at the present through a rear-view mirror. We march backwards 
> >> into the future.” 
> >> 
> >> http://www.warrenellis.com/?p=14314 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msg/django-users/-/uYEguNGN3CsJ. 
> > To post to this group, send email to 
> > django...@googlegroups.com<javascript:>. 
>
> > To unsubscribe from this group, send email to 
> > django-users...@googlegroups.com <javascript:>. 
> > For more options, visit this group at 
> > http://groups.google.com/group/django-users?hl=en. 
>
>
>
> -- 
> ...we look at the present day through a rear-view mirror. This is 
> something Marshall McLuhan said back in the Sixties, when the world 
> was in the grip of authentic-seeming future narratives. He said, “We 
> look at the present through a rear-view mirror. We march backwards 
> into the future.” 
>
> http://www.warrenellis.com/?p=14314 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/7Y18reXx9R8J.
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