A simple Django app to track create,update and delete actions.
drf-history is a simple django rest framework app to track actions performed in a django app and to also gets the current request. The actions being tracked are POST, DELETE, PUT and PATCH
Data being captured is
|user||The current loggedin user making the request|
|request data(body)||Data being sent (POST, PATCH and PUT)|
|response data||response data after the request is complete|
|table_name||name of the model the request is affecting|
|instance_id||The id of the created, updated or deleted model instance|
|method||The request method i.e POST, DELETE, PUT or PATCH|
|created_at||Date time object for when the request is being carried out|
|path||path the request is coming from|
track_actionsto your INSTALLED_APPS setting
INSTALLED_APPS = [ ..., 'track_actions', ]
track_actions.requestMiddleware.RequestMiddlewarein settings under middlewares
MIDDLEWARE = [ ... , 'track_actions.requestMiddleware.RequestMiddleware', ]
python manage.py migrate track_actionsto create the History model.
`python manage.py migrate track_actions`
After this every POST, UPDATE and DELETE action will be recorded in your database under the history model.
To get the current request
To get the current request in progress anywhere in the application.
Import the relevant class.
from track_actions.requestMiddleware import RequestMiddleware
2 Get the current request object.
current_request = RequestMiddleware.get_request_data()
To access the get history endpoint
In your project's url file
Register the url in the urlpattern
visit the url in the browser or on postman
you should be able to see all the recorded history if you have
admin priveleges and you are authenticated.
You can create your own endpoint to view all history from the History model by importing it in your views or serializers.
`from track_actions.models import History`
This package will only work if you have a user in a request and a user model in your database.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size drf_history-0.0.9-py3-none-any.whl (8.8 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size drf-history-0.0.9.tar.gz (6.6 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for drf_history-0.0.9-py3-none-any.whl