Найти - Пользователи
Полная версия: perms в шаблоне работает ?
Начало » Django » perms в шаблоне работает ?
1
Maddy
Вот наткнулся на непонятку …
          {% if perms.iapp.can_control_major %}
<li> <a href="/major/">Информация мэра</a></li>
{% endif %}
не работает
а если пойти через вьюху
  def iView(request,tag=None, user=None):
canControlMajor=user.has_perm('iapp.can_control_major')
Info={'profile':profile,
'canCtrlMajor':canControlMajor
#'xxxInfo':user.get_all_permissions()
}
render_to_response('info.html', Info)

info.html:
{% if canCtrlMajor %}
<li> <a href="/major/">Информация мэра</a></li>
{% endif %}
то все путем ….

Если rtfm покажите плиз пальцем куда ….
Александр Кошелев
У вас должен быть установлен контекст процессор django.core.context_processors.auth: http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-auth
И соотвественно вы должны использовать RequestContex
Maddy
таки вроде есть …. и perms объект просматривается
django.core.context_processors.auth
Toggle Context
{'messages': ,
‘perms’: <django.core.context_processors.PermWrapper object at 0x015E4310>,
‘user’: <User: Crazy>}
…. но ничего не делает :(
ps: или низя одновременно render_to_response c perms использовать ?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB