0

main_menu.html

<li {% if report_menu %}class="current"{% endif %}><a href="{% url incident.views.index %}"> Reports </a></li>
{% if is_superuser%}<li {% if about_menu %}class="current"{% endif %}><a href="{% url incident.views.about_me %}">Settings</a>{% endif %}

スーパーユーザー以外の設定メニューを許可したくないので、テンプレート{% if is_superuser %}settings{% endif %}でこのように検証しましたが、それでもスーパーユーザーログイン以外の設定メニューが表示されています。

私のサイトにスーパーユーザー以外がログインしている場合、main_menu.html の上記の設定メニューが表示されないはずです。これを行うにはヘルプが必要です。

これを解決するには助けが必要です。

ありがとう

4

1 に答える 1

2

ビューでコンテキストを構築する際にuser.is_superuserを使用する必要があります。RequestContext

{% if user.is_superuser %}settings{% endif %}
于 2013-06-26T04:28:14.277 に答える