Z
Z
zelsky2015-08-02 21:26:24
Django
zelsky, 2015-08-02 21:26:24

Django bootstrap alerts?

Here you need to send an alert from twitter bootstrap using django directly from the view when the exception is fired. As it is possible to realzoivat Google showed little.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
zelsky, 2015-08-03
@zelsky

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="#">&times;</a>
      {{ message }}
    </div>
  {% endfor %}
{% endif %}

S
sim3x, 2015-08-02
@sim3x

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 question

Ask a Question

731 491 924 answers to any question