In Django, how can I access a parameter in a template? -


from view i'm doing following:

return render(request, 'yabe/login.html', {'error': true}) 

in template i'm trying

{% if error %}     <div class="error">authentication error. please try again</div>  {% endif %} 

but it's not working

if you're using django.shortcuts.render should work. problem might have contextmanager overriding context variable. try this:

your view:

from django.shortcuts import render  def your_view(request):     ...     return render(request, 'yabe/login.html', {'errorusedjusthere': true}) 

your template:

{% if errorusedjusthere %}     <div class="error">authentication error. please try again</div>  {% endif %} 

extra. use django debug toolbar see variables set in context.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -