So in my project, I have a model Chat with many Messages. I want to have ChatSerializer with MessageSerializer inside and many=True.
However, I only want to include the last 50 Message models.
class MessageSerializer(serializers.ModelSerializer):
class Meta(object):
model = Message
fields = '__all__'
class ChatSerializer(serializers.ModelSerializer):
messages = MessageSerializer(many=True)
class Meta:
model = Chat
fields = '__all__'
Is there anything I can add to the messages = MessageSerializer(many=True) to make it only return the latest 50 messages?
Thanks!
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)