如何在python中修改导入的变量(how to modify imported variables in python)
python
在a.py ,我导入了django的settings.py ,我需要修改settings.DEBUG 。
但是如何在python脚本中执行此操作?
我这样做但没有改变, settings.DEBUG=False
In a.py ,I imported django's settings.py,I Need to Modify settings.DEBUG .
but how to do it in python script?
I did this but nothing changed , settings.DEBUG=False
最满意答案
https://docs.djangoproject.com/en/dev/topics/settings/#altering-settings-at-runtime我认为这是你想要的。
就像它说:
from django.conf import settings settings.DEBUG = True # Don't do this!The only place you should assign to settings is in a settings file.
祝好运!
https://docs.djangoproject.com/en/dev/topics/settings/#altering-settings-at-runtime I think this is you want.
Just like it saied:
from django.conf import settings settings.DEBUG = True # Don't do this!The only place you should assign to settings is in a settings file.
Good luck!
更多推荐
发布评论