[Answer]-Django standalone script : need to import django.db to see logging

1👍

Instead of writing standalone script you should to write django custom command.

Answering your question this behavior is achieved by accessing django.conf.settings attribute in django.db module.

Django settings is lazy object. Once any of settings property requested, lazy settings object initialize settings object and perform configuration of logging.

Look at chain of methods in LazySettings:

  1. __getattr__ call _setup
  2. _setup call _configure_logging

Leave a comment