выдает такую ошибку :
Cannot resolve keyword 'page' into field. Choices are: id, model, vendor, volume, year
Views.py
from .models import Car
from .serializers import CarSerializer
from rest_framework.viewsets import ModelViewSet
from rest_framework.pagination import PageNumberPagination
class MyPag(PageNumberPagination):
page_size = 10
ordering = ['id']
class CarViewSet(ModelViewSet):
serializer_class = CarSerializer
queryset = Car.objects.all()
pagination_class = MyPag
def filter_queryset(self, queryset):
for k, v in self.request.query_params.items():
if k == 'cursor':
continue
queryset = queryset.filter(**{k: v})
return queryset
Models.py:
from django.db import models
# Create your models here.
class Car(models.Model):
vendor = models.CharField(max_length=280)
model = models.CharField(max_length=280)
year = models.PositiveSmallIntegerField()
volume = models.PositiveSmallIntegerField()
class Meta:
unique_together = [
('vendor','model','year'),
]
ошибка возникает при переходе страниц в Django REST
без метода filter_queryset все работает