No module named views, Django tutorial

1,761 views
Skip to first unread message

tm

unread,
Mar 22, 2008, 6:33:43 PM3/22/08
to Django users
Hey Guys and Gals,

I am trying to setup and run the tutorial program from the Django
tutorial at djangobook.com. I have my PYTHONPATH variable set to
include my project path which includes views.py, but am unable to run
it via the django lite server. Each time I run it I get this error...

ImportError at /time/
No module named views
Request Method: GET
Request URL: http://127.0.0.1:8000/time/
Exception Type: ImportError
Exception Value: No module named views
Exception Location: C:\Python25\Lib\site-packages\django\core
\urlresolvers.py in _get_urlconf_module, line 177

I have the file views.py in my pythonpath, and it is referenced in
urls.py just like in the example. It just won't connect. Am I
missing something? Any help greatly appreciated.

here is the trackback info


Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in
get_response
68. callback, callback_args, callback_kwargs =
resolver.resolve(request.path)
File "C:\Python25\Lib\site-packages\django\core\urlresolvers.py" in
resolve
160. for pattern in self.urlconf_module.urlpatterns:
File "C:\Python25\Lib\site-packages\django\core\urlresolvers.py" in
_get_urlconf_module
177. self._urlconf_module = __import__(self.urlconf_name, {}, {},
[''])

ImportError at /time/
No module named views

any help greatly appreciated! Thanks, tm

Evert Rol

unread,
Mar 22, 2008, 7:05:15 PM3/22/08
to django...@googlegroups.com
> I am trying to setup and run the tutorial program from the Django
> tutorial at djangobook.com. I have my PYTHONPATH variable set to
> include my project path which includes views.py, but am unable to run
> it via the django lite server. Each time I run it I get this error...
>
> ImportError at /time/
> No module named views
> Request Method: GET
> Request URL: http://127.0.0.1:8000/time/
> Exception Type: ImportError
> Exception Value: No module named views
> Exception Location: C:\Python25\Lib\site-packages\django\core
> \urlresolvers.py in _get_urlconf_module, line 177
>
> I have the file views.py in my pythonpath, and it is referenced in
> urls.py just like in the example. It just won't connect. Am I
> missing something? Any help greatly appreciated.

If you followed the tutorial, it'd be hard to make a big mistake.
Possibly it's a simple typo (unless you really simply copy-pasted
things); could you send what you have for views.py and urls.py?
And perhaps to check there's really nothing wrong with your
PYTHONPATH, trying printing it from the 'django' shell:
python manage.py shell
>>> import sys
>>> print sys.path

tm

unread,
Mar 22, 2008, 7:17:56 PM3/22/08
to Django users
Ok, I have it working, but in a different directory "c:\sourcecode
\mysite"

I had my project in an apache directory so maybe it has something to
do with permissions. I have full rights on everything so will
investigate and post a solution. Thanks for your help!

tm

lancemiller777

unread,
Apr 23, 2008, 1:52:59 AM4/23/08
to Django users
I am having the same error. Note: A month into learning Python also.
I just did this:
pydoc -w /usr/local/google_appengine/lib/django/django/core/
urlresolvers.py
outputs a nice html file:
urlresolvers.html
And in it is a link to the source code viewed in the web browser.
Python rocks.
Now if I can just figure out Django.

Anyway the error happens in this function:
def _get_urlconf_module(self):
try:
return self._urlconf_module
except AttributeError:
try:
self._urlconf_module = __import__(self.urlconf_name,
{}, {}, [''])
except ValueError, e:
# Invalid urlconf_name, such as "foo.bar." (note
trailing period)
raise ImproperlyConfigured, "Error while importing
URLconf %r: %s" % (self.urlconf_name, e)
return self._urlconf_module

The Google Django Help page does not help in showing what/where this
URL config thing is supposed to happen.
http://code.google.com/appengine/articles/django.html


the devel

unread,
Apr 23, 2008, 8:02:23 AM4/23/08
to Django users
> I had my project in an apache directory so maybe it has something to
> do with permissions.

Quoted from the Django Tutorial:

If your background is in PHP, you’re probably used to putting code
under the Web server’s document root (in a place such as /var/www).
With Django, you don’t do that. It’s not a good idea to put any of
this Python code within your Web server’s document root, because it
risks the possibility that people may be able to view your code over
the Web. That’s not good for security.

Put your code in some directory outside of the document root, such as /
home/mycode.
Reply all
Reply to author
Forward
0 new messages