[Django]-Why does manage.py execution script run twice when using it under if __name__ == "__main__"

11👍

Your code is launching the runserver command, which causes Django to use the reloader, which in turn means that your code is reexecuted as if it were entered on the command line. If you use --noreload when you launch runserver the issue will disappear.

So basically, the same facility that automatically reloads Django when you modify your source files, which is so useful in development, is now causing your code to execute twice.

👤Louis

Leave a comment