[Django]-Why does django run everything twice?

32👍

It’s not running it twice, it’s forking to 2 processes and each one of those is running it once.

Answered by: why is init module in django project loaded twice

It should be loaded only once… per process. I’m guessing that
manage.py forks, and that two separate processes are launched.

and an article.

To verify this if you add this to your settings.py

import os
print(os.getpid())

It will print out 2 different process id numbers showing that it’s spawned 2 processes.

You can read more about forking on wikipedia.

This also seems a duplicate of:

django – settings.py seems to load multiple times?

👤Ewan

Leave a comment