Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
There are cooler
https://docs.djangoproject.com/en/1.8/ref/contrib/...
{% if messages %}
{% for message in messages %}
<div{% if message.tags %} class="alert alert-{{ message.tags }}"{% endif %}>
<a class="close" data-dismiss="alert" href="#">×</a>
{{ message }}
</div>
{% endfor %}
{% endif %}
0. Exception in python will result in a 500 error on the server, so it will not work to give an alert
1. If you need to show an error, then you need to provide a variable in the view, and check it in the template
def foo_view(request):
return render(request, 'foo_tpl.html', {'is_error': False})
{% if is_error %}
shit happens
{% endif%}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question