Django paths, developing in windows, deploying on linux

后端 未结 4 1038
悲哀的现实
悲哀的现实 2021-02-09 10:47

I\'m developing Django apps on my local windows machine then deploying to a hosted linux server. The format for paths is different between the two and manually replacing before

4条回答
  •  独厮守ぢ
    2021-02-09 11:16

    in your settings.py add the following lines

    import os.path
    
    SETTINGS_PATH = os.path.abspath(os.path.dirname(__file__))  
    head, tail = os.path.split(SETTINGS_PATH)
    
    #add some directories to the path
    import sys
    sys.path.append(os.path.join(head, "apps"))
    #do what you want with SETTINGS_PATH
    

提交回复
热议问题