Commit 59608255 authored by Давид Ли's avatar Давид Ли

lesson 57

parent 2665861b
......@@ -68,6 +68,26 @@
</div>
</nav>
<div class="container">
{% if messages %}
{% for message in messages %}
<div class="alert alert-dismisable fade show
{% if message.level == DEFAULT_MESSAGE_LEVELS.ERROR %}
alert-danger
{% elif message.level == DEFAULT_MESSAGE_LEVELS.SUCCESS %}
alert-success
{% elif message.level == DEFAULT_MESSAGE_LEVELS.INFO %}
alert-primary
{% else %}
alert-secondary
{% endif %}" role="alert">
{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% endfor %}
{% endif %}
{% block title %}{% endblock %}
{% block content %}{% endblock %}
......
from urllib.parse import urlencode
from django.contrib import messages
from django.urls import reverse, reverse_lazy
from django.db.models import Q
from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin, UserPassesTestMixin
......@@ -25,7 +26,11 @@ class ArticleIndexView(ListView):
def dispatch(self, request, *args, **kwargs):
self.form = self.get_search_form()
self.search_value = self.get_search_value()
session = request.session
messages.add_message(self.request, messages.SUCCESS, 'Все круто!')
messages.add_message(self.request, messages.DEBUG, 'Debug')
messages.add_message(self.request, messages.INFO, 'Info')
messages.add_message(self.request, messages.WARNING, 'warning')
messages.add_message(self.request, messages.ERROR, 'error')
return super().dispatch(request, *args, **kwargs)
def get_context_data(self, *, object_list=None, **kwargs):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment