diff --git a/config/users/urls.py b/config/users/urls.py index 1d5c8d0..d58ced6 100644 --- a/config/users/urls.py +++ b/config/users/urls.py @@ -1,5 +1,7 @@ from django.urls import path +from django.contrib.auth.views import LogoutView + from .views import SignUpView, CustomLoginView app_name = 'user' @@ -7,4 +9,5 @@ urlpatterns = [ path('signup/', SignUpView.as_view(), name='signup'), path('login/', CustomLoginView.as_view(), name='login'), + path('logout/', LogoutView.as_view(), name='logout'), ] \ No newline at end of file diff --git a/config/users/views.py b/config/users/views.py index dab3294..ce01ab9 100644 --- a/config/users/views.py +++ b/config/users/views.py @@ -11,11 +11,11 @@ class SignUpView(CreateView): template_name = 'users/signup.html' - form = UserCreationForm + form_class = UserCreationForm success_url = reverse_lazy('photo:list') - def form_valid(self, form): + to_return = super().form_valid(form) user = authenticate( username=form.cleaned_data["username"], @@ -24,8 +24,8 @@ def form_valid(self, form): login(self.request, user) - return super().form_valid(form) - + return to_return + class CustomLoginView(views.LoginView): template_name = 'users/login.html' \ No newline at end of file