我正在尝试将Django Reversion与我的django-rest一起使用,但我仍然对此感到困惑,或者我只是无法获得我想要的内容Document
。
Here what i tried
Settings
INSTALLED_APPS = [
....
'reversion'
]
MIDDLEWARE = [
'reversion.middleware.RevisionMiddleware'
]
In Model
@reversion.register()
class History(models.Model):
pass
In ModelViewset
from reversion.views import RevisionMixin
class HistoryViewset(RevisionMixin, viewsets.ModelViewSet):
queryset = History.objects.all()
serializer_class = HistorySerializer
filter_backends = (filters.DjangoFilterBackend,)
# if pagination page = none, it will return all page
def list(self, request, *args, **kwargs):
queryset = self.filter_queryset(self.get_queryset())
if 'page' in request.query_params:
page = self.paginate_queryset(queryset)
if page is not None:
serializer = self.get_serializer(page, many=True)
return self.get_paginated_response(serializer.data)
serializer = self.get_serializer(queryset, many=True)
return Response(serializer.data)
然后我尝试更新My Model
并尝试从api 端点GET
请求,我得到了null值。
我错过了什么???
我会感谢你所有的帮助。谢谢...