Setting DJANGO_SETTINGS_MODULE under virtualenv?

前端 未结 2 1148
心在旅途
心在旅途 2021-02-04 08:16

I want the environment variable DJANGO_SETTINGS_MODULE to change depending on what I say for workon. It seemed to me that I want to set it in .virtualenvs/postmkvirtualen

相关标签:
2条回答
  • 2021-02-04 09:10

    You were on the right track, but you want to use the postactivate hook instead of postmkvirtualenv.

    It won't restore automatically on deactivate. Thankfully there is postdeactivate hook that you can use to manually restore any environmental variables that you changed on activate.

    0 讨论(0)
  • 2021-02-04 09:13

    One way I've done that before is by appending an export statement to the end of ./bin/activate

    export DJANGO_SETTINGS_MODULE="myproject.settings"
    
    0 讨论(0)
提交回复
热议问题