Wednesday, March 27, 2013

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

On Wed, Mar 27, 2013 at 3:32 PM, +Emmanuel <elusenji@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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment