Using Python's os.path, how do I go up one directory?

前端 未结 14 1748
陌清茗
陌清茗 2020-12-07 07:47

I recently upgrade Django from v1.3.1 to v1.4.

In my old settings.py I have

TEMPLATE_DIRS = (
    os.path.join(os.path.dirname( __file_         


        
14条回答
  •  轮回少年
    2020-12-07 08:34

    os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'templates'))
    

    As far as where the templates folder should go, I don't know since Django 1.4 just came out and I haven't looked at it yet. You should probably ask another question on SE to solve that issue.

    You can also use normpath to clean up the path, rather than abspath. However, in this situation, Django expects an absolute path rather than a relative path.

    For cross platform compatability, use os.pardir instead of '..'.

提交回复
热议问题