Hello I am working with a template in which I want to display or hide a block of html depending if the user is superUser or not. The code is the following:
<h1> What user.is_superuser returns: {{ user.is_superuser }}</h1>
{% if user.is_superuser %}
<h1>Superuser</h1>
{% else %}
<h1>Mindundi</h1>
{% endif %}
The idea is to show "Superuser" to the superusers or "mMindundi" otherwise.
But here is the output I am getting:
I have been pulling my hair out and can't find a solution. I know the problems come with the ```"0"````being a string instead a int, so everything get parsed to True... Why is this happening??? I know a fix would be parsing it to int... but I want to fix it other way if possible.
For reference, I am using these packages:
asgiref==3.2.3
certifi==2019.6.16
chardet==3.0.4
defusedxml==0.6.0
Django==2.2.3
django-markdownx==2.0.28
django-model-utils==3.2.0
docxtpl==0.6.3
idna==2.8
Jinja2==2.10.1
lxml==4.3.4
Markdown==3.1.1
MarkupSafe==1.1.1
oauthlib==3.0.2
Pillow==6.1.0
PyJWT==1.7.1
python-docx==0.8.7
python-social-auth==0.3.6
python3-openid==3.1.0
pytz==2019.1
requests==2.22.0
requests-oauthlib==1.2.0
six==1.12.0
social-auth-app-django==3.1.0
social-auth-core==3.2.0
sqlparse==0.3.0
urllib3==1.25.3
xlrd==1.2.0
I found what the problem was. I had done a manual migration this summer, fixing some tables that couldn't be migrated automatically. Somewhere in the process I modified the table auth_user
changing some columns from integer to text, as soon as I replaced that everything started to work as intended.