Exesize
1from django.contrib.auth.views import LoginView, LogoutView2from django.urls import reverse_lazy3from django.views.generic import CreateView, UpdateView4
5from authapp.forms import CustomUserCreationForm, CustomUserChangeForm6from authapp.models import User7
8
9class CustomLoginView(LoginView):10template_name = 'authapp/login.html'11extra_context = {12'title': 'Вход пользователя'13}14
15
16class RegisterView(CreateView):17model = User18form_class = CustomUserCreationForm19success_url = reverse_lazy('authapp:login')20
21
22class CustomLogoutView(LogoutView):23template_name = 'mainapp/index.html'24
25
26class EditView(UpdateView):27model = User28form_class = CustomUserChangeForm29template_name = 'authapp/edit.html'30
31def get_object(self, queryset=None):32return self.request.user33
34def get_success_url(self):35return reverse_lazy('authapp:edit', args=[self.request.user.pk])36
37