1#views.py
2from rest_framework import generics
3
4
5class Login(generics.CreateAPIView):
6 serializer_class = MySerializerClass
7 def create(self, request, *args, **kwargs):
8 request.data._mutable = True
9 request.data['username'] = "example@mail.com"
10 request.data._mutable = False
11
12#serializes.py
13from rest_framework import serializers
14
15
16class MySerializerClass(serializers.Serializer):
17 username = serializers.CharField(required=False)
18 password = serializers.CharField(required=False)
19 class Meta:
20 fields = ('username', 'password')
21