仅当我使一个模型具有对同一模型的2个继承时,才会发生这种情况:
colorControlNormal
一切正常,但是访问第二页会给我一个空数组:
第一页:
class Word(models.Model):
cuvint = models.ForeignKey(KeyWordsMapping, on_delete=models.CASCADE, related_name="%(class)s_cuvint")
frequency = models.IntegerField()
is_stem = models.BooleanField()
score_nr = models.ForeignKey(KeyWordsMapping, on_delete=models.CASCADE, related_name="%(class)s_score_nr")
department_id = models.ForeignKey(Department, on_delete=models.CASCADE, blank=True, null=True)
seniority_id = models.ForeignKey(Seniority, on_delete=models.CASCADE, blank=True, null=True)
第二页:
{
"count": 311,
"next": "http://127.0.0.1:8000/api/words?limit=1&offset=1",
"previous": null,
"results": [
{
"cuvint": "QA",
"frequency": 4,
"is_stem": false,
"score_nr": 100,
"department_id": "Quality Assurance",
"seniority_id": null
}
]
}
我也在管理面板中查看,同样的问题仍然存在。
视图:
{
"count": 311,
"next": "http://127.0.0.1:8000/api/words?limit=1&offset=2",
"previous": "http://127.0.0.1:8000/api/words?limit=1",
"results": []
}
序列化器:
class WordList(mixins.ListModelMixin,
mixins.RetrieveModelMixin,
generics.GenericAPIView):
queryset = Word.objects.all()
serializer_class = WordSerializer
def get(self, request, *args, **kwargs):
return self.list(request, *args, **kwargs)