Authentication in Django templates
I recently came across a problem when adding user accounts to a Django application I’m currently working on: I wanted to access information about the current user, e.g. whether they were anonymous or logged in, so that I could display a login message or a link to their homepage respectively. This sounds like a relatively simple thing to accomplish but the problem was that I didn’t want to have to look up the current user’s information in every view method and pass it to the template. Luckily Django provides a way of dealing with this very situation by providing a special template ‘context’. (more…)
no comments yet


