Django 1.5 tutorial error: 'module' has no attribute 'StackedInLine'

637 views
Skip to first unread message

+Emmanuel

unread,
Mar 27, 2013, 11:32:06 AM3/27/13
to django...@googlegroups.com
Hello there,

I am working through the django tutorial at djangoproject.com. So far everything works out fine until Section 2.4.6 (customizing the admin form). Django throws an error:  'module' has no attribute 'StackedInLine'. I checked around and this seems to work:
if you use import to include a module, make sure you don’t have a file named just the same as the module you are trying to include in current directory. It seems python takes preference for local files over modules thus import fails.
Problem is, how now do I call the Poll admin module if it's name has been changed to say admin2.py since naming it admin.py conflicts with the main django admin.
I hope this makes sense!
Thanks.

Tom Evans

unread,
Mar 27, 2013, 11:46:23 AM3/27/13
to django...@googlegroups.com
On Wed, Mar 27, 2013 at 3:32 PM, +Emmanuel <elus...@gmail.com> wrote:
> Hello there,
>
> I am working through the django tutorial at djangoproject.com. So far
> everything works out fine until Section 2.4.6 (customizing the admin form).
> Django throws an error: 'module' has no attribute 'StackedInLine'. I
> checked around and this seems to work:
> if you use import to include a module, make sure you don’t have a file named
> just the same as the module you are trying to include in current directory.
> It seems python takes preference for local files over modules thus import
> fails.

Mmmm, yes, but this is not what is happening. If you have this structure:

polls
├── __init__.py
├── admin.py
├── models.py
└── views.py

and in the admin.py write "from django.contrib import admin", it will
not get confused about the "admin.py" in the same directory. If you
had a file called "django.py", then that would confuse the importing.

> Problem is, how now do I call the Poll admin module if it's name has been
> changed to say admin2.py since naming it admin.py conflicts with the main
> django admin.

The admin file in your poll app must be called admin.py, else it will
not be discovered.

The easiest way to work out why you are getting this error, would be
to give us the complete error message - there should be multiple lines
- and the contents of your admin.py.

Cheers

Tom

Karen Tracey

unread,
Mar 27, 2013, 11:48:18 AM3/27/13
to django...@googlegroups.com
On Wed, Mar 27, 2013 at 11:32 AM, +Emmanuel <elus...@gmail.com> wrote:
Hello there,

I am working through the django tutorial at djangoproject.com. So far everything works out fine until Section 2.4.6 (customizing the admin form). Django throws an error:  'module' has no attribute 'StackedInLine'.

Right, the L in StackedInLine should NOT be capitalized, it should be just an initial capital letter on Inline: StackedInline

+Emmanuel

unread,
Apr 2, 2013, 2:50:43 AM4/2/13
to django...@googlegroups.com
Thanks Karen! That fixed the problem :-)

+Emmanuel

unread,
Apr 2, 2013, 2:51:38 AM4/2/13
to django...@googlegroups.com
Thanks for the useful replies!

Richard Roberts

unread,
Jan 22, 2018, 5:08:05 PM1/22/18
to Django users
Awesome Spot Karen. 
Reply all
Reply to author
Forward
0 new messages