Django helper app for logging ID.
Project description
Kantan log is a simple Django helper app. This app supports logging to Django Model’s created_by, updated_by. At http requests interception, too.
Installation
shell>pip install djangokantanlog
Usage
Installed apps:
INSTALLED_APPS = [
...
'kantanlog.apps.KantanlogConfig',
]
Middleware:
MIDDLEWARE = [
...
'kantanlog.middlewares.KantanlogMiddleware',
]
Settings
KLOG_TARGET_APP_LABELS
Default: None
Target apps, settings as app-label:
KLOG_TARGET_APP_LABELS = (
...
'myapp',
)
KLOG_BACKEND
Default: None
As interface, getting user.
e.g.
# -*- coding: utf8 -*-
from logging import getLogger
from kantanlog.backends import KantanlogDefaultBackend
from rest_framework_jwt.authentication import JSONWebTokenAuthentication
from rest_framework_jwt.settings import api_settings
logger = getLogger(__name__)
payload_handler = api_settings.JWT_PAYLOAD_HANDLER
encode_handler = api_settings.JWT_ENCODE_HANDLER
class MyappBackend(KantanlogDefaultBackend):
def __init__(self):
super().__init__()
def get_user(self, request):
user = super().get_user(request)
if user.is_authenticated:
return user
ja = JSONWebTokenAuthentication()
if ja.get_jwt_value(request):
user, jwt = ja.authenticate(request)
return user
return user
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
djangokantanlog-0.0.2.tar.gz
(6.3 kB
view hashes)
Built Distribution
Close
Hashes for djangokantanlog-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 179072863aaa02f6cbb4fd3c13cf7799032d5fe7e7686733f8d2c2dcca4558dd |
|
MD5 | 3e615f1be607683c4eece0e863d27993 |
|
BLAKE2b-256 | 9760f2a24898d5db2a35057202ac7e0659b42afeb20b57c37014fc43c5280e2e |