-1

I am having a hard time with some django errors that have appeared in my code. These errors have raised (I think) when I upgraded from python 2.7 to python 3.6.

The errors are caused because some functions return a string instead of his primitive value. For example in a template in which I have html that should only be shown to superusers I have been using:

{% if user.is_superuser %}

This call should return an 0 (false) or 1, (true) whether the user is superuser or not.

But now this is not working as expected, because it returns '0' or '1'. I must then parse to int the call to get the proper result:

{% if int.user.is_superuser %}

I find this very unsettling solution. This shouldn't behave like this and there are more internal functions I had to fix because behave in the same fashion.

I am currently using Django 2.2.3 and python 3.6.

Any help for a clean solution is much appreciated.

Jesus
  • 655
  • 1
  • 7
  • 21

1 Answers1

0
{% if user.is_superuser %}
    <!-- html block -->
{% endif %}

this statement is a condition in Django template like a simple if clause in python

mtf
  • 329
  • 2
  • 13