Moving django apps into subfolder and url.py error

后端 未结 4 987
梦谈多话
梦谈多话 2021-02-13 13:33

I have a question about putting django apps into \"apps\" subdirectory. I have the app called “faktura” in a project_root. I didn’t like the fact it lies there and I want to sto

4条回答
  •  自闭症患者
    2021-02-13 14:28

    To keep your Django applications in a subfolder (such as apps/), first add the following to your settings.py:

    import os

    PROJECT_ROOT = os.path.dirname(__file__)

    Then in manage.py:

    Right under #!/usr/bin/env python add:

    import sys

    from os.path import abspath, dirname, join

    from site import addsitedir

    Right before if __name__ == "__main__" : add:

    sys.path.insert(0, join(settings.PROJECT_ROOT, "apps"))

提交回复
热议问题