I have next ModelSerializers.
I need the statistics data display at 6 days range by default (see date field in StatisticSerializer). User can to change this date range (from frontend get two parameters: start_date and end_date, which not is in Models and Serializers.
How can I make this functional?
serializers
class StatisticSerializer(serializers.ModelSerializer):
class Meta:
model = Statistic
fields = ['date', 'clicks', 'page_views']
class UserStatisticSerializer(serializers.ModelSerializer):
statistics = StatisticSerializer(many=True)
class Meta:
model = User
fields = [
'first_name', 'last_name', 'gender', 'ip_address', 'statistics',
]
views
class UserStatisticApiView(RetrieveAPIView):
serializer_class = UserStatisticSerializer
queryset = User.objects.all()