-1

I'm trying to have information about an object show up if the user is a super user. Normally the information is hidden unless the object's public attribute is true. The object.public part works and {{user.is_superuser}} works as expected but {% if user.is_superuser %} does not.

<h1>Player Techniques</h1>
    <h2>{{user.is_superuser}}</h2>
    {% for object in techniques %}
        {% if user.is_superuser or object.public%}
            {% include "unlimited/technique.html" %}
        {% endif %}
    {% endfor %}

here are my settings

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [],
        "APP_DIRS": True,
        "OPTIONS": {
            "context_processors": [
                "django.template.context_processors.debug",
                "django.template.context_processors.request",
                "django.contrib.auth.context_processors.auth",
                "django.contrib.messages.context_processors.messages",
            ],
        },
    },
]

I have also tried request.user.is_superuser with the same results, correctly displaying True for superuser and False otherwise in the h2, but not passing the if.

1 Answers1

-1

Use {% if request.user.is_superuser == True %} Django templating engine doesn't work the same was as python

Neeraj VB
  • 1
  • 1