Importing "app" level with django 1.4?

I have a django app that I developed in 1.2 days. Now I am trying to cast it to project format 1.4.

The old way my project was set up was as follows:

django_project/
    settings.py
    manage.py
    urls.py
    app1/
    app2/
    app3/

      

I change it to use the new manage.py file and my directories look like this:

django_project/
    manage.py
    project
        urls.py
        wsgi.py
        app1/
        app2/
        app3/

      

The problem is, in all my code, I import things like this:

from app1.models import SomeModel

      

which is now giving me an import error. Making this fix:

from project.app1.models import SomeModel

      

I really don't have to go through the whole project to change all these imports. Is there something I am missing? Is there an easier way? Or is this the way you should do it?

+3


source to share


2 answers


Applications should not be placed in a module project

. Django startapp

puts them in the root of the project as it did before. project

module is the place for all project settings, urls and similar stuff. Your applications should remain outside, at the root of the project.



+4


source


You can keep your current layout as it will work fine. For new projects, I think you can start hosting your applications in the "project" module. If you check 1.4 of the Release Notes , you will see the recommended layout. But if you are developing generics applications (which you can use across multiple projects), the project root is probably the best place.



+1


source







All Articles