Django Installed Apps Location

前端 未结 3 2145
野性不改
野性不改 2020-12-31 04:04

I am an experienced PHP programmer using Django for the first time, and I think it is incredible!

I have a project that has a lot of apps, so I wanted to group them

3条回答
  •  感动是毒
    2020-12-31 04:47

    Your top-level urls.py (also named in your settings.py) must be able to use a simple "import" statement to get your applications.

    Does import project.apps.app1.urls work? If not, then your PYTHONPATH isn't set up properly, or you didn't install your project in Python's site-packages directory.

    I suggest using the PYTHONPATH environment variable, instead of installing into site-packages. Django applications (to me, anyway) seem easier to manage when outside site-packages.

    We do the following:

    • Django projects go in /opt/project/.

    • PYTHONPATH includes /opt/project.

    • Our settings.py uses apps.this and apps.that (note that the project part of the name is part of the PYTHONPATH, not part of the import.

提交回复
热议问题