View django setting source

form django .conf impirt settings this is true profile settings

form django.conf import golbal_settings django global configuration file

 Why is there all the local settings file name if the capital

First, the first step to a global dictionary that big assignment is large dictionary os.environ then setdefault value 

"DJANGO_SETTINGS_MODULE", "book_admin.settings") 
the value of the big dictionary, but you do not have this DJANGO_SETTINGS_MODULE which it will perform the assignment executing the assignment, and then look at the file settingas look inside the interior of the django settings, first
settong is a object class point into this category then he will get you behind this is equivalent to DJANGO_SETTINGS_MODULE book_admin.settings (this is your local settings file) and then assignment, then
in your assignment of this variable name passed a class, first in this class, first obtain the file name of a file, then dir it acquired all of the variable names in this file first judge
judges all variable names you this file is not capitalized, if it is then first of all an assignment by setattr the operation then operation getattr your file name as an object in the first place
to the second loop on the variable name is removed name corresponding to the value of this variable is then assigned, then you next passed in this class this value is settings_module your
local setting that File and then give self an assignment operator, were you assigned through the value is equal to your setting file and importlib by the action of this module is that
you can get to your you through all of the variable names in your file names to point out your files variable corresponding value is then assigned to a variable name
this time your variable name is your local settings file and it can dot syntax to get all your setttings variable name
then the next step is to get through a for loop dir this variable file names inside you all the variable name, and then cycle out to see your judgment is not capitalized if this is so new assignment
Django will take you inside of this would have been assigned the value of the variable names in again replaced assignment out

Guess you like

Origin www.cnblogs.com/yangxinpython/p/11545006.html