Why do I need the DJANGO_SETTINGS_MODULE set?

前端 未结 3 657
挽巷
挽巷 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:56

    By default, manage.py looks for a settings module in the same directory as itself. If it doesn't find one, it bombs out with a message to use django-admin.py instead. It doesn't actually set up the environemnt until it runs execute_manager. If you need to run your hooks before calling your management functions, the practice I've seen suggested is to put them in the relevant app's models.py.

提交回复
热议问题