Django paths, developing in windows, deploying on linux

后端 未结 4 1037
悲哀的现实
悲哀的现实 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:06

    We have a situation very similar to yours, and we've been using different paths in settings, basing on sys.platform. Something like this:

    import os, sys
    DEVELOPMENT_MODE = sys.platform == 'win32'
    if DEVELOPMENT_MODE:
        HOME_DIR = 'c:\\django-root\\'
    else:
        HOME_DIR = '/home/django-root/'
    

    It works quite OK - assumed all development is being done on Windows.

提交回复
热议问题