I currently have an API view setup as follows:
class WeatherObservationSerializer(serializers.ModelSerializer): dew_point = serializers.Field(source='dew_point') wind_gust = serializers.Field(source='get_wind_gust') class Meta: model = WeatherObservation fields = ('id', 'station', 'temperature', 'pressure', 'humidity', 'wind_direction', 'wind_speed', 'rainfall', 'date', 'dew_point', 'wind_gust') class WeatherObservationList(generics.ListCreateAPIView): model = WeatherObservation serializer_class = WeatherObservationSerializer permission_classes = (permissions.IsAuthenticatedOrReadOnly,) def get_queryset(self): queryset = WeatherObservation.objects.all() min_date = self.request.QUERY_PARAMS.get('min_date', None) station = self.request.QUERY_PARAMS.get('station', None) if min_date is not None: queryset = queryset.filter(date__gte=min_date) if station is not None: queryset = queryset.filter(station=station) return queryset
My settings.py contains: REST_FRAMEWORK = {'PAGINATE_BY': 50, 'PAGINATE_BY_PARAM': 'page'}
When I make an API request, for example: / api / weather / observations /? station = 2 & page = 2 & min_date = 2013-3-14 I return only two results. If it is for pages 3, 3 of the result, etc. Is there something that I am doing wrong that is causing this problem?
Greetings.
source share