How to disable logging messages in Django shell?

675 views Asked by At

I'm using pycharm to run my Django project and I did set some logging settings in my settings.py:

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "filters": {
        "require_debug_false": {
            "()": "django.utils.log.RequireDebugFalse",
        },
    },
    "formatters": {
        "verbose": {
            "format": "{levelname} {asctime} {module} {process:d} {thread:d} {message}",
            "style": "{",
        },
    },
    "handlers": {
        "console": {
            "class": "logging.StreamHandler",
            "stream": "ext://sys.stdout",
            "formatter": "verbose",
        },
        "mail_admins": {
            "level": "ERROR",
            "class": "django.utils.log.AdminEmailHandler",
            "filters": ["require_debug_false"],
        },
    },
    "loggers": {
        "django.request": {
            "handlers": ["mail_admins"],
            "level": "ERROR",
            "propagate": True,
        },
    },
    "root": {
        "handlers": ["console"],
        "level": "DEBUG",
    },
}

The problem is when I'm in the Django shell. In the Django shell when I press the tab button to auto-complete my code imports or calling methods,some logging messages just appear.

PS D:\Django Projects\Company-Task\APITask> python .\manage.py shell

DEBUG 2022-04-27 12:53:34,021 proactor_events 8988 5720 Using proactor: IocpProactor Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] Type 'copyright', 'credits' or 'license' for more information IPython 8.2.0 -- An enhanced Interactive Python. Type '?' for help.

DEBUG 2022-04-27 12:53:34,145 proactor_events 8988 5720 Using proactor: IocpProactor

In 1: from task_auth.DEBUG 2022-04-27 12:53:49,375 diff 8988 5720 diff parser start DEBUG 2022-04-27 12:53:49,376 diff 8988 5720 line_lengths old: 1; new: 1
DEBUG 2022-04-27 12:53:49,376 diff 8988 5720 -> code[replace] old[1:1] new[1:1]
DEBUG 2022-04-27 12:53:49,378 diff 8988 5720 parse_part from 1 to 1 (to 0 in part parser) DEBUG 2022-04-27 12:53:49,378 diff 8988 5720 diff parser end
DEBUG 2022-04-27 12:53:49,396 cache 8988 5720 pickle loaded: D:\Django Projects\Company-Task\APITask\task_auth_init_.py DEBUG 2022-04-27 12:53:49,456 cache 8988 5720 pickle loaded: D:\Django Projects\Company-Task\APITask\task_auth\migrations_init_.py DEBUG 2022-04-27 12:53:49,462 cache 8988 5720 pickle loaded: D:\Django Projects\Company-Task\APITask\task_auth\models.py models import DEBUG 2022-04-27 12:53:58,520 diff 8988 5720 diff parser

start DEBUG 2022-04-27 12:53:58,521 diff 8988 5720 line_lengths old: 1; new: 1
DEBUG 2022-04-27 12:53:58,522 diff 8988 5720 -> code[replace] old[1:1] new[1:1]
DEBUG 2022-04-27 12:53:58,523 diff 8988 5720 parse_part from 1 to 2 (to 0 in part parser) DEBUG 2022-04-27 12:53:58,524 diff 8988 5720 diff parser end
DEBUG 2022-04-27 12:53:58,753 cache 8988 5720 pickle loaded: C:\Users\Mobin Tadbir\Envs\django4\lib\site-packages\jedi\third_party\typeshed\stdlib\3\builtins.pyi User

How can I disable these logging messages in the Django shell?

0

There are 0 answers