I am developing an API, using django-rest-framework-mongoengine with MongoDb, I want to append additional fields to the request from the serializer on the base of user inputs, for example If user enters keyword=@rohit49khatri, I want to append two more fields to the request by manipulating keyword, like type=username, username=rohit49khatri
Here's my code:
Serializer
class SocialFeedCreateSerializer(DocumentSerializer):
type = 'username'
class Meta:
model = SocialFeedSearchTerm
fields = [
'keyword',
'type',
]
read_only_fields = [
'type'
]
View
class SocialFeedCreateAPIView(CreateAPIView):
queryset = SocialFeed.objects.all()
serializer_class = SocialFeedCreateSerializer
def perform_create(self, serializer):
print(self.request.POST.get('type'))
But when I print type parameter, It gives None
Please help me save some time. Thanks.