How to keep all my django applications in specific folder

前端 未结 7 902
逝去的感伤
逝去的感伤 2020-12-12 16:59

I have a Django project, let\'s say \"project1\". Typical folder structure for applications is:

/project1/
         /app1/
         /app2/
         ...
             


        
7条回答
  •  再見小時候
    2020-12-12 17:39

    You can add your apps folder to your python path by inserting the following in your settings.py:

    import os
    import sys
    
    PROJECT_ROOT = os.path.dirname(__file__)
    sys.path.insert(0, os.path.join(PROJECT_ROOT, 'apps'))
    

    Then you can use all the apps in this folder just in the same way as they were in your project root!

提交回复
热议问题