I have this kind of setup :
- Overridden BaseRunserverCommand that adds another option (–token) that would get a string token.
- Store it in the app called “vault” as a global variable
- Then continue executing the BaseRunserverCommand
Now later when I try to get the value of this global variable after the server started, I am unable to see the value. Is this going out of scope? How to store this one time token that is entered before the django starts?
Judging by the name of the command line option, this sounds like a configuration variable — why not put it in
settings.pylike all the other configurations?If it’s a secure value that you don’t want checked in to version control, one pattern I’ve seen is to put secure or environment-sensitive (i.e. only makes sense in production or development) configurations in a
local_settings.pyfile which is not checked in to version control, then add to the end of yoursettings.py:(Note that some people like to invert the import relationship and then use
--settingson the command line withrunserver— this works, too, but requires that you always remember to use--settings.)