Why do I need the DJANGO_SETTINGS_MODULE set?

前端 未结 3 653
挽巷
挽巷 2021-02-02 00:42

Every time I log on to my server through SSH I need to type the following:

export DJANGO_SETTINGS_MODULE=settings

if I do not any usage of the

3条回答
  •  借酒劲吻你
    2021-02-02 00:52

    You need to set the DJANGO_SETTINGS_MODULE environment variable because it's how Django knows what your settings module is called (so you can have different ones per project or for testing and development.) You can set it in the scripts themselves before you import django (directly or indirectly) but that won't do much good when you run the Django-provided scripts.

    The easiest solution is probably to just set DJANGO_SETTINGS_MODULE in your shell's startup scripts, so you won't have to set it manually anymore. The usual files to add it to are .bash_profile and .bashrc (if you do indeed use bash.)

提交回复
热议问题