First time here? Check out the FAQ!
1

cannot import other apps' models from writers.py

I have an app whose models and views resides in my site's project directory (in contrast to askbot, which resides in /usr/lib/...). When I try import its models from an askbot's writers.py as follows:

from myapp import models

I get this error:

ImproperlyConfigured: Error importing middleware askbot.middleware.view_log: "cannot import name models"

Any hints on what may be causing this error or how to debug it?

theactiveactor's avatar
167
theactiveactor
asked 2010-07-24 21:22:13 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

Hi again. The error sounds to me like a circular dependency issue (a importing b and b importing a at the same time), but I may be wrong...

This can even be unrelated to askbot - does import statement succeed on its own?

You can try this:

python manage.py shell
>>> from myapp import models

Are you trying to modify writers.py by adding the statement

from myapp import models

? And your copy of askbot is installed into /usr/lib... If so, then I recommend to keep askbot in your user space - it certainly does not have to be in /usr/lib - because it is more convinient to edit in directory where you have normal write permissions.

The only reason askbot goes into /usr/lib/ is to allow multisite deployments.

With your setup you can just recursively copy contents of /askbot/ directory wherever it's installed to your project directory.

If you plan to modify askbot source code then you'll save yourlself a lot of trouble if you add it to your git repository. That way you will be able to easily pull upgrades. Of course it's best to keep applications decoupled as much as possible. Maybe we can together think of some orderly way to build extensions...

Use pylint - I like it a lot - helps me catch so many errors do you debug less.

Evgeny's avatar
13.2k
Evgeny
updated 2010-07-24 22:13:26 -0500, answered 2010-07-24 21:49:07 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments