0

I have a django application structured like this...

app_foo
  __init__.py
  urls.py
  views.py
  models.py
  bar_app
    __init__.py
    ...
  bar_app...

By using distutils, I can get the application to install into the python path under the "app_foo" module name.

However, any of the code inside of the "bar_app" python files which refers to things inside the django app relatively does not work when executed from the python path. For example,

from bar_app.views import stuff

I know that I can go through the app and change all the references to be absolute. For example,

from app_foo.bar_app.views import stuff

My question:

Is there anyway I can get all of the apps inside "app_foo" to also be on the python path?

Conceptually this would be similar to saying from app_foo import * for the entire path.

1 Answer 1

1

You can do

from .bar_app.views import stuff

http://docs.python.org/whatsnew/2.5.html#pep-328-absolute-and-relative-imports

Sign up to request clarification or add additional context in comments.

1 Comment

this is definitely better than specifying app name. i'll do this if there's not a way to get them all on the path

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.