1
You can use your own template tag to achieve it or put it in your controller’s logic.
Have a look at this snippet: http://www.djangosnippets.org/snippets/302/
0
If what you need to know is whether you should render a piece of HTML, and you are going to reuse this rule in other templates, you may try to use django.template.RequestContext
and make it an accessable status variable in templates in need.
def context(request):
return {'render_a_panel' : request.user.username in ('Jim', 'Tom')}
Of course, this only works if your rule is based on request.
- [Django]-Django/Python convert PDF using shell (os.system/Popen) not working in production
- [Django]-A better django datetime filter at the admin panel
Source:stackexchange.com