task_manager/views.py
from django.contrib import messages
from django.contrib.auth.views import LoginView, LogoutView
from django.contrib.messages.views import SuccessMessageMixin
from django.urls import reverse_lazy
from django.utils.translation import gettext as _
from django.views.generic import TemplateView
class IndexTemplateView(TemplateView):
template_name = 'index.html'
class UserLoginView(SuccessMessageMixin, LoginView):
template_name = 'users/login.html'
next_page = reverse_lazy('index')
success_message = _('You are logged in')
class UserLogoutView(SuccessMessageMixin, LogoutView):
next_page = reverse_lazy('index')
def dispatch(self, request, *args, **kwargs):
messages.info(request, _('You are logged out'))
return super().dispatch(request, *args, **kwargs)