Skip to main content

A package for adding a django-reversion history endpoint to django-rest-framework ModelViewSet

Project description

django-reversion-rest-framework

A package for adding a django-reversion history endpoint to django-rest-framework ModelViewSet.

Configuration

Follow the official website for the installation and the integration of django-reversion in your project, otherwise future steps won't work.

You might need to enable the ReversionMiddleware for storing a version for each API change.
Follow the instructions here, you should add 'reversion.middleware.RevisionMiddleware' to your MIDDLEWARE setting.

Using the HistoryModelViewSet

The HistoryModelViewSet extends django-rest-framework's ModelViewSet adding a GET history action in the detail, displaying a list of all revisions of that specific record.

You can use the HistoryModelViewSet in place of the ModelViewSet during viewsets definition.

from reversion_rest_framework.viewsets import HistoryModelViewSet


class MyModelViewSet(HistoryModelViewSet):
    # ...

Then if your endpoint exposes on the url /my-models/ you can get the history of a record using my-models/<pk>/history/.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-reversion-rest-framework-0.1.0.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page