I am a newbie to Python and Django. I have been playing with the Polls solution available in VS 2017 to help learn Django and Python.
My question has to do this execution of python script files. By strategically adding print statements within the .py
files of this solution I am trying to understand the order in which the execution occurs.
The first file executed (that is listed on the Solutions Explorer) is manage.py
.
From there execution jumps to settings.py
but it passes through the __init__
file first (which is empty but I added a print statement anyways so I was able to track it to that point).
The settings.py
file as expected sets variables, etc.. but the last file in the settings.py
file is not a call, it is just an assignment of STATIC_ROOT
, yet the execution jumps to the models.py
via the _init_
once the last line of the settings.py
is executed. The question is how and why ?
Also when the last line of a python script is reached what happens?
Is there an order to execution of various "Packages" or "Modules"?
Are script files linked using import statements?