Import issues since newforms-admin

2 views
Skip to first unread message

Julien Phalip

unread,
Jul 8, 2008, 7:20:54 PM7/8/08
to Django users
Hi,

There's an issue that arose as I upgraded an external app of mine to
newforms-admin.

I created the conventional admin.py, which does all the registration
business, and did "import admin" in the module's __init__.py

After I did that, I got some import errors at compilation time (or
say, project's launching time):

"ImportError: cannot import name MenuItem"

"MenuItem" is in the external app (freshly upgraded to nfa), and the
import that raises the error is made in the project's app.

The external app was included at the top of the INSTALLED_APPS
setting. Putting it at the end of INSTALLED_APPS solved the issue.

I thought that the order didn't matter in INSTALLED_APPS. Have I
missed something or have I possibly misconfigured my external app or
my project's apps?

Is that a known issue (and if so, what's the proper way around it?),
or is that worth filing a ticket?

Thanks!

Julien

Malcolm Tredinnick

unread,
Jul 8, 2008, 7:50:19 PM7/8/08
to django...@googlegroups.com

On Tue, 2008-07-08 at 16:20 -0700, Julien Phalip wrote:
> Hi,
>
> There's an issue that arose as I upgraded an external app of mine to
> newforms-admin.
>
> I created the conventional admin.py, which does all the registration
> business, and did "import admin" in the module's __init__.py
>
> After I did that, I got some import errors at compilation time (or
> say, project's launching time):
>
> "ImportError: cannot import name MenuItem"
>
> "MenuItem" is in the external app (freshly upgraded to nfa), and the
> import that raises the error is made in the project's app.

It's a bit (for me, at least) to keep track of what structure you're
describing here. You are using the word "project" to mean something that
isn't clear. Could you give a small layout of the directory structure
please.

It's not impossible to imagine something like the problem you're
describing happening depending upon import paths. Remember that when you
do "from foo import models", Python first has to parse and execute the
code in "foo/__init__.py", so things might not be fully constructed.
But, again, it's hard to tell without concrete code. If you can
construct a very small example that demonstrates the problem (like,
literally, as few lines as possible. To the point that if you remove any
more lines, the problem goes away) then you've got something you can put
in a bug report because then other people can try to repeat the problem
and diagnose it.

I'm not intimately familiar with how newforms is doing imports or
recommended practices over there, but if this type of problem is
cropping up, it's worth knowing about it so that we can either document
"don't do that" or get things fixed if possible.

Again, I'm not saying that what you're seeing is a bug or necessarily a
problem in Django. I don't understand the problem you're describing from
the English-language version. Code speaks more clearly here, I think.

Regards,
Malcolm


Julien Phalip

unread,
Jul 9, 2008, 12:10:55 AM7/9/08
to Django users
Thanks for the tip Malcolm.

I've prepared some very simple code to illustrate the problem. I can't
find a way to attach files in this mailing list. Should I open a
ticket and post it there?

Thanks,

Julien

On Jul 9, 9:50 am, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:

Malcolm Tredinnick

unread,
Jul 9, 2008, 12:14:14 AM7/9/08
to django...@googlegroups.com

On Tue, 2008-07-08 at 21:10 -0700, Julien Phalip wrote:
> Thanks for the tip Malcolm.
>
> I've prepared some very simple code to illustrate the problem. I can't
> find a way to attach files in this mailing list. Should I open a
> ticket and post it there?

Yes. Trac is the only place where things will not be forgotten.

Regards,
Malcolm


Julien Phalip

unread,
Jul 9, 2008, 12:31:11 AM7/9/08
to Django users
Ok, I've just opened a ticket and posted some code illustrating the
issue:
http://code.djangoproject.com/ticket/7684

Thanks,

Julien

On Jul 9, 2:14 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
Reply all
Reply to author
Forward
0 new messages