I have a view login():
from django.http import HttpRequest
from useraccounts.models import BadIP
def login(request):
client_address = request.META['REMOTE_ADDR']
client_instance = BadIP.objects.get(ip_address=client_address)
if client_instance.ban_state == True:
return render(request, 'login.html', {'banned':True})
else:
return render(request, 'login.html', {'banned':False})
And a template:
{% if banned == False %}
<p>Content</p>
{% endif %}
{% if banned == True %}
<p>Content #2</p>
{% endif %}
Under these standards, neither of the two paragraphs will be rendered in the template. However, if I change the instances in the code where True and False appear to strings, suddenly the template renders fine. Why does this happen, and is there any way to change this behavior to be more obvious/semantically correct?
They are boolean variables already! No need to compare to them
TrueorFalse. Try this: