File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 4
4
5
5
6
6
class ProposalSerializer (serializers .ModelSerializer ):
7
+ username = serializers .SerializerMethodField ()
8
+ category_name = serializers .SerializerMethodField ()
7
9
accepted = serializers .BooleanField (read_only = True )
8
10
created_at = serializers .DateTimeField (read_only = True )
9
11
updated_at = serializers .DateTimeField (read_only = True )
@@ -12,7 +14,7 @@ class Meta:
12
14
model = Proposal
13
15
fields = [
14
16
"id" ,
15
- "user " ,
17
+ "username " ,
16
18
"title" ,
17
19
"brief" ,
18
20
"desc" ,
@@ -21,6 +23,7 @@ class Meta:
21
23
"duration" ,
22
24
"language" ,
23
25
"category" ,
26
+ "category_name" ,
24
27
"accepted" ,
25
28
"introduction" ,
26
29
"video_url" ,
@@ -30,6 +33,15 @@ class Meta:
30
33
"updated_at" ,
31
34
]
32
35
36
+ @staticmethod
37
+ def get_username (obj : Proposal ):
38
+ return "{}{}" .format (obj .user .last_name , obj .user .first_name )
39
+
40
+ @staticmethod
41
+ def get_category_name (obj : Proposal ):
42
+ return obj .category .name
43
+
44
+
33
45
34
46
class ProposalListSerializer (serializers .ModelSerializer ):
35
47
class Meta :
Original file line number Diff line number Diff line change 3
3
4
4
from program .viewsets import ProposalViewSet
5
5
6
- router = DefaultRouter ()
7
- router .register ("" , ProposalViewSet , basename = "program " )
6
+ session_router = DefaultRouter ()
7
+ session_router .register ("sessions " , ProposalViewSet , basename = "session " )
8
8
9
9
urlpatterns = [
10
- path ("" , include (router .urls )),
10
+ path ("" , include (session_router .urls )),
11
11
]
You can’t perform that action at this time.
0 commit comments