質問編集履歴
1
質問を具体的にしました
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,6 +6,124 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
+
|
10
|
+
|
11
|
+
urls.py
|
12
|
+
|
13
|
+
```
|
14
|
+
|
15
|
+
"""api URL Configuration
|
16
|
+
|
17
|
+
The `urlpatterns` list routes URLs to views. For more information please see:
|
18
|
+
|
19
|
+
https://docs.djangoproject.com/en/2.1/topics/http/urls/
|
20
|
+
|
21
|
+
Examples:
|
22
|
+
|
23
|
+
Function views
|
24
|
+
|
25
|
+
1. Add an import: from my_app import views
|
26
|
+
|
27
|
+
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
28
|
+
|
29
|
+
Class-based views
|
30
|
+
|
31
|
+
1. Add an import: from other_app.views import Home
|
32
|
+
|
33
|
+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
34
|
+
|
35
|
+
Including another URLconf
|
36
|
+
|
37
|
+
1. Import the include() function: from django.urls import include, path
|
38
|
+
|
39
|
+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
40
|
+
|
41
|
+
"""
|
42
|
+
|
43
|
+
from django.contrib import admin
|
44
|
+
|
45
|
+
from django.urls import path, include, re_path
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
urlpatterns = [
|
50
|
+
|
51
|
+
path('admin/', admin.site.urls),
|
52
|
+
|
53
|
+
re_path(r'(?P<version>(v1|v2))/', include('api.chat.urls'))
|
54
|
+
|
55
|
+
]
|
56
|
+
|
57
|
+
```
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
/chat/url.py
|
62
|
+
|
63
|
+
```
|
64
|
+
|
65
|
+
from django.urls import path, include
|
66
|
+
|
67
|
+
from rest_framework.routers import DefaultRouter
|
68
|
+
|
69
|
+
from rest_framework_extensions.routers import NestedRouterMixin
|
70
|
+
|
71
|
+
from rest_framework_simplejwt import views as jwt_views
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
from api.chat import views
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
class NestedDefaultRouter(NestedRouterMixin, DefaultRouter):
|
82
|
+
|
83
|
+
pass
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
router = NestedDefaultRouter()
|
90
|
+
|
91
|
+
rooms_router = router.register('rooms', views.RoomViewSet)
|
92
|
+
|
93
|
+
rooms_router.register(
|
94
|
+
|
95
|
+
'messages',
|
96
|
+
|
97
|
+
views.MessageViewSet,
|
98
|
+
|
99
|
+
base_name='room-messages',
|
100
|
+
|
101
|
+
parents_query_lookups=['room']
|
102
|
+
|
103
|
+
)
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
urlpatterns = [
|
110
|
+
|
111
|
+
path('', include(router.urls)),
|
112
|
+
|
113
|
+
path('users/', views.CreateUserView.as_view()),
|
114
|
+
|
115
|
+
path('users/<int:pk>/', views.DetailUserView.as_view()),
|
116
|
+
|
117
|
+
path('auth/login', jwt_views.TokenObtainPairView.as_view()),
|
118
|
+
|
119
|
+
path('auth/refresh', jwt_views.TokenRefreshView.as_view()),
|
120
|
+
|
121
|
+
]
|
122
|
+
|
123
|
+
```
|
124
|
+
|
125
|
+
|
126
|
+
|
9
127
|
models.py
|
10
128
|
|
11
129
|
```
|
@@ -216,7 +334,7 @@
|
|
216
334
|
|
217
335
|
|
218
336
|
|
219
|
-
signal.py
|
337
|
+
signals.py
|
220
338
|
|
221
339
|
|
222
340
|
|