# for Authentication
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth import login
class LoginFormView(FormView):
form_class = AuthenticationForm
template_name = "fighter/login.html"
success_url = "/demo"
def form_valid(self, form):
self.user = form.get_user()
login(self.request, self.user)
return super(LoginFormView, self).form_valid(form)
def form_invalid(self, form):
form.add_error(None, u'Вы кто такие? Я вас не звал!');
return super(LoginFormView, self).form_invalid(form)