-
Notifications
You must be signed in to change notification settings - Fork 0
/
dumps.py
29 lines (27 loc) · 1.4 KB
/
dumps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# class RegistrationViewSet(viewsets.ModelViewSet):
# queryset = User.objects.all()
# serializer_class = StudentRegistrationSerializer
# http_method_names = ['post']
# def get_serializer_class(self):
# if self.action =='post':
# data = self.request.data
# if data['role'] == "Student":
# return StudentRegistrationSerializer
# elif data['role'] == "Head of Department":
# return HODRegistrationSerializer
# elif data['role'] == "Teacher":
# return TeacherRegistrationSerializer
# return self.serializer_class
# def create(self, request, *args, **kwargs):
# data = self.request.data
# serializer_class = self.get_serializer_class()
# print("Serializer Class:", serializer_class) # Add this line for debugging
# if serializer_class is None:
# return Response({"message": "No valid serializer class found."}, status=status.HTTP_400_BAD_REQUEST)
# serializer = serializer_class(data=request.data)
# if serializer.is_valid():
# serializer.save()
# return Response(serializer.data, status=status.HTTP_201_CREATED)
# return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
# def list(self, request, *args, **kwargs):
# return Response({"message":"Invalid Request Method"})