Django Python异常模型、管理器、日志处理器、中间件和excepthook
项目描述
安装
$ pip install django-command-exception
settings.py
INSTALLED_APPS+=['django_command_exception']
migrate
$ python manage.py migrate
模型
模型 | 表 | 列/字段 |
---|---|---|
CommandException |
django_command_exception |
id,command,exc_class,exc_message,exc_traceback,created_at |
示例
call_command
from django_command_exception.models import CommandException
try:
call_command(name)
except Exception as e:
CommandException(command=name).save()
BaseCommand
from django_command_exception.models import CommandException
class BaseCommand(BaseCommand):
def execute(self, *args, **options):
try:
return super().execute(*args, **options)
except Exception as e:
CommandException(command=type(self).__module__.split('.')[-1]).save()
CommandExceptionMixin
from django_command_exception.mixins import CommandExceptionMixin
class Command(CommandExceptionMixin,BaseCommand):
def handle(self, *args, **options):
try:
...
except Exception as e:
self.error(e)
项目详情
关闭
django_command_exception-1.0.2.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | c4f0bdc40ac60fc64b0ea0b5122e0af5119791de4c3929a2a4619fcafbffcf52 |
|
MD5 | cf2192d771dfa21835f308062bf93d1d |
|
BLAKE2b-256 | ac51c5296b4dac2478b778987392e892ebaa77dd035dfa838cf4aeaf92e45a7f |