23π
I guess you are facing the problem described in this post: Django logging with RotatingFileHandler error
That is, when running Django development server, actually there are two processes running.
by default, two processes of Django servers are running. One is the
actual server, while the other is to detect changes in the code and
reload the server. Therefore, settings.py is imported twice, and
consequently the two processes are accessing the log file at the same
time.
As advised there, try
python manage.py runserver --noreload
15π
As describe in other answers python manage.py runserver --noreload
will work. But hereβs another solution that still works with code reload.
Add this at the end of your settings.py
if DEBUG and os.environ.get('RUN_MAIN', None) != 'true':
LOGGING = {}
python manage.py runserver
starts a python process that launches your server in a child python process. Each time the parent detects a change it recreates a new child. The problem is that the log rotation by the child process fails because the parent still has a handle on that file. This solution tells the parent that there are no log file.
- [Django]-Is this the right way to do dependency injection in Django?
- [Django]-Django: list all reverse relations of a model
- [Django]-Django: sqlite for dev, mysql for prod?