-
Book Overview & Buying
-
Table Of Contents
Mastering Django: Core
By :
The currently logged-in user and their permissions are made available in the template context when you use RequestContext.
When rendering a template RequestContext, the currently logged-in user, either a User instance or an AnonymousUser instance, is stored in the template variable
{{ user }}:
{% if user.is_authenticated %}
<p>Welcome, {{ user.username }}. Thanks for logging in.</p>
{% else %}
<p>Welcome, new user. Please log in.</p>
{% endif %}
This template context variable is not available if a RequestContext is not being used.
The currently logged-in user's permissions are stored in the template variable
{{ perms }}. This is an instance of Django.contrib.auth.context_processors.PermWrapper, which is a template-friendly proxy of permissions. In the {{ perms }} object, single-attribute lookup is a proxy to User.has_module_perms. This example would display True if the logged-in...
Change the font size
Change margin width
Change background colour