No module named views

1,698 views
Skip to first unread message

Martin

unread,
Nov 15, 2007, 12:34:12 PM11/15/07
to Django users
Hi,

i'm having little trouble with my apps views. i'm getting errors:

Exception Type: ImproperlyConfigured
Exception Value: Error while importing URLconf 'project.app.urls': No
module named views

i have my urls.py in project dir, and urls.py in my app dir, all
containing dicts, templates etc.
could someone please point me where to look to solve this? since i'm a
newbie in django, this is probably a stupid question: if i'm getting
no module named views, does this mean that django can't find urls.py
or is it because views.py is empty (everything is in urls.py)?

thanks, martin

RajeshD

unread,
Nov 15, 2007, 2:50:17 PM11/15/07
to Django users
> could someone please point me where to look to solve this? since i'm a
> newbie in django, this is probably a stupid question: if i'm getting
> no module named views, does this mean that django can't find urls.py
> or is it because views.py is empty (everything is in urls.py)?

Care to paste here your urls.py file from the project/apps directory?

Martin

unread,
Nov 15, 2007, 3:50:38 PM11/15/07
to Django users
yes, of course.

---------------------
from django.views.generic.create_update import create_object,
update_object
from django.views.generic.simple import redirect_to
from voting.views import vote_on_object
from project.komentar.models import *

komentar_vote_dict = {
'model': Komentar,
'template_object_name': 'komentar',
}
komentar_date_dict = {
'queryset': Komentar.objects.all().select_related(),
'date_field': 'created',
'template_object_name': 'komentar',
}
komentar_latest_dict = {
'queryset': Komentar.objects.order_by('-
created').select_related(),
'template_object_name': 'komentar',
'extra_context' : { 'sort' : 'latest' },
'allow_empty': 'true',
'paginate_by': 25,
'template_name' : 'komentar/komentar_list.html',
}
urlpatterns = patterns('',
(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?
P<slug>[-\w]+)/$', object_detail, dict(komentar_date_dict,
slug_field='slug')),
(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/
$', archive_day, dict(komentar_date_dict,
allow_empty=True)),
(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/
$', archive_month,
dict(komentar_date_dict, allow_empty=True)),

(r'^(?P<object_id>\d+)/(?P<direction>up|down|clear)/?$',
vote_on_object, komentar_vote_dict),
(r'^edit/(?P<object_id>\d+)/$', update_object,
dict(model=Komentar, login_required=True, template_name="komentar/
komentar_edit_form.html")),
(r'^create/$', create_object,
dict(model=Komentar, login_required=True, post_save_redirect="/
komentar/latest/")),
(r'^latest/$', object_list,
dict(komentar_latest_dict)),
(r'^$', redirect_to, {'url': '/komentar/
latest/'}),
)

this is urls.py from project/app.
i'll paste urls.py from project too:

------------------------------------
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template,
redirect_to
from registration.views import register
from project.user_details.views import create_user_profile


urlpatterns = patterns('',
(r'^komentar/$', include('project.komentar.urls')),
(r'^users/',
include('project.user_details.urls')),
(r'^accounts/register/$', register, {'profile_callback':
create_user_profile}),
(r'^accounts/', include('registration.urls')),
(r'^accounts/profile/$', redirect_to, {'url': '/'}),
(r'^accounts/$', direct_to_template, {'template':
'registration/index.html'}),
(r'^$', direct_to_template, {'template':
'homepage.html'}),
(r'^admin/', include('django.contrib.admin.urls')),
(r'^r/',
include('django.conf.urls.shortcut')),
(r'',
include('django.contrib.flatpages.urls')),
)


I'm sorry for this long paste.. i could you dpaste.
thanks, martin

RajeshD

unread,
Nov 15, 2007, 5:10:31 PM11/15/07
to Django users
Since the error you are seeing is in 'project.app.urls' and the error
says "No
module named views", it seems that the statement that's failing in /
project/app/urls is this one:

from voting.views import vote_on_object

This would mean that voting.views is not a valid Python module:

1. Is there an __init__.py file in the "voting" directory?
2. Is the "voting" directory in your Python path?
3. Check that /voting/views.py has no errors and that it defines the
method vote_on_object.



RajeshD

unread,
Nov 15, 2007, 5:12:41 PM11/15/07
to Django users
>
> I'm sorry for this long paste.. i could you dpaste.
> thanks, martin

Yes, it's probably better to dpaste it when you have a lot of code
like that. That way, your indentation is preserved and it's easier for
others to review your code. I should've recommended it when I asked
you to paste here.

Martin

unread,
Nov 15, 2007, 5:28:46 PM11/15/07
to Django users
Thanks, RajeshD!

the problem was, indeed, "from voting.views import vote_on_object".
voting dir was in my py path but i used svn and "the true" voting dir
was actually in a subdir.. anyway, i've put it in python path and now
it works. i knew there was something strange, because this code works
fine on my server.

thanks again for quick reply and solved problem!
bye, martin

Kenneth Gonsalves

unread,
Nov 15, 2007, 8:29:40 PM11/15/07
to django...@googlegroups.com

On 15-Nov-07, at 11:04 PM, Martin wrote:

> or is it because views.py is empty (everything is in urls.py)?

'everything' being what? if your urls are pointing to views.py and if
views is empty the error is logical. Could you paste your urls.py - I
am very curious to know *what* you mean by 'everything'

--

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/


Reply all
Reply to author
Forward
0 new messages