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: ()
Target apps, settings as app-label:
KLOG_TARGET_APP_LABELS = (
...
'myapp',
)
KLOG_BACKEND
Default: kantanlog.backends.KantanlogDefaultBackend
As interface, getting user.
e.g.
# at settings.py
KLOG_BACKEND = 'dotted.path.to.MyappBackend'
...
# -*- 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.3.tar.gz
(6.4 kB
view hashes)
Built Distribution
Close
Hashes for djangokantanlog-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e211ef50a437d0f937cf3b79022348aecc76d0c0c5fbed930d49213e83d4ed39 |
|
MD5 | 7cc0882ea4604d9c048f63236f681471 |
|
BLAKE2b-256 | 9678b61480901fb3b460116dd1f6e31b5a516ca5caaa81748b31c4da073fc92b |