Skip to content

Commit eeb5780

Browse files
committed
add labels create.html
1 parent c2c78ea commit eeb5780

File tree

5 files changed

+13
-54
lines changed

5 files changed

+13
-54
lines changed

db.sqlite3

0 Bytes
Binary file not shown.

task_manager/settings.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@
9999

100100
WSGI_APPLICATION = 'task_manager.wsgi.application'
101101

102-
LOGIN_REDIRECT_URL = "index"
103-
LOGOUT_REDIRECT_URL = "index"
104102

105103

106104

@@ -156,3 +154,6 @@
156154
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
157155

158156
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
157+
158+
LOGOUT_REDIRECT_URL = '/'
159+
LOGIN_REDIRECT_URL = "index"

task_manager/templates/labels/index.html

Lines changed: 0 additions & 45 deletions
This file was deleted.

task_manager/urls.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
from django.contrib import admin
22
from django.urls import path, include
33
from task_manager import views
4-
from .users.views import LoginUserView, LogoutUserView
4+
from .users.views import LoginUserView, LogoutAllowGetView
5+
from django.contrib.auth.views import LogoutView
56
from django.conf import settings
67
from django.conf.urls.static import static
78

89
app_name = "task_manager"
910

11+
1012
urlpatterns = [
1113
path("admin/", admin.site.urls),
1214
path("", views.IndexView.as_view(), name="index"),
1315
path("login/", LoginUserView.as_view(), name="login"),
14-
path("logout/", LogoutUserView.as_view(), name="logout"),
16+
path('logout/', LogoutAllowGetView.as_view(next_page='/'), name='logout'),
1517
path("users/", include("task_manager.users.urls"), name="users"),
1618
path("statuses/", include("task_manager.statuses.urls"), name="statuses"),
1719
path("tasks/", include("task_manager.tasks.urls"), name="tasks"),

task_manager/users/views.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ class LoginUserView(SuccessMessageMixin, LoginView):
3636
success_message = _("You are logged in")
3737

3838

39-
class LogoutUserView(LogoutView):
40-
def dispatch(self, request, *args, **kwargs):
41-
response = super().dispatch(request, *args, **kwargs)
42-
messages.add_message(request, messages.INFO, _("You are logged out"))
43-
return response
39+
class LogoutAllowGetView(LogoutView):
40+
http_method_names = ['get', 'post']
41+
42+
def get(self, request, *args, **kwargs):
43+
# Чтобы GET вызывал logout, просто вызываем post
44+
return self.post(request, *args, **kwargs)
4445

4546

4647
class UpdateUserView(

0 commit comments

Comments
 (0)