ImportError - No module named index

583 views
Skip to first unread message

jakob....@gmail.com

unread,
Aug 24, 2006, 8:47:01 AM8/24/06
to Django users
I really have tried to solve this on my own, but despite my best
efforts I wasn't able to fix it. Anyway, I have created a project
using:
django-admin.py startproject mysite
Then I added an app using:
python manage.py startapp hello
All worked well. I added the app in installed apps list and added the
following url
(r'^site/$', include('mysite.hello.views.index')),
into urls.py file.
As you can see it's all pretty basic.

And now when I try to open localhost:8000/site/I get the following
error:
ImportError at /site/
No module named index
Request Method: GET
Request URL: http://localhost:8000/site/
Exception Type: ImportError
Exception Value: No module named index
Exception Location: <unknown> in ?, line ?

With a really usefull trackback:

* <unknown> in ?

I'm at a complete loss here. What's wrong with it?

PS: I'm using django from the svn on SuSE 10.1. I got the same error
when I tried apache2.

Bryan L. Fordham

unread,
Aug 24, 2006, 1:55:46 PM8/24/06
to django...@googlegroups.com
> All worked well. I added the app in installed apps list and added the
> following url
> (r'^site/$', include('mysite.hello.views.index')),
> into urls.py file.

you either want include('mysite.hello.urls') to include the urls.py in your
app, or
(r'^site/$', 'mysite.hello.views.index'),
to execute that view when they visit site/

You're trying to include the view as urls, and that won't work 8)

--
Bryan L. Fordham
socialistsushi.com
Sushi For Everyone

jakob....@gmail.com

unread,
Aug 24, 2006, 2:00:41 PM8/24/06
to Django users

Oh *gawd* I'm such a twat!

Thank you!

du...@habmalnefrage.de

unread,
Aug 24, 2006, 2:02:22 PM8/24/06
to django...@googlegroups.com
Hi Jakob,

this situation is not unknown to me :)

First you should check if you have __init__.py files along mysite.hello.views. They can be empty but thats what python expects.

Than check if mysite.hello or mysite is in the settings.py in INSTALLED_APPS. If so use the shell-mode:

python manage.py shell # (you maybe need to set a DJANGO_SETTINGS_MODULE)
import mysite
import mysite.hello
import mysite.hello.views
from mysite.hello.views import index
import urls
from urls import urlpatterns

You will get an error somewhere and that error message points you to the problem.

Regards,
Dirk
--


Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

Reply all
Reply to author
Forward
0 new messages