How do I do that? split up 2 files?
Just put it in any file you like and import it somewhere in your main settings file.
So you could set up new settings my_new_settings.py
anywhere django can reach, and import it at the end of your real settings.py
.
# settings.py
# ...
from my_new_settings import *
这些页面可能会有所帮助: 关于SO的讨论, djangoproject.com的讨论
Although my solution is not as complex as the ones above, they fit my simple needs: I have some imports in my settings.py file:
try:
from settings_local import *
except ImportError:
pass
try:
from settings_production import *
except ImportError:
pass
And then I have a settings_local.py file in my local development folder (which I don't upload to the server) and where I overwrite local settings. Then I have a settings_production.py server where I keep settings needed for the production environment.
You can use this technique to import other settings files as well.
创建new_settings.py
文件以包含settings.py
一部分,然后将该文件导入所需的位置。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.