I think you have to add "from views import *" to urls.py and make sure you
have a method called contact in your view.

Cheers,

On 09/12/2011 12:10 PM, "Jim Byrnes" <jf_byr...@comcast.net> wrote:

> I am trying to learning django by working my way through The Definitive
> Guide to django (vers 1.1). I am running django 1.1.1 on Ubuntu 10.04.
>
> I get the following error when trying to import urls:
>
> >>> import urls
> Traceback (most recent call last):
>  File "<console>", line 1, in <module>
>  File "/home/jfb/MyProgs/djcode/**mysite/urls.py", line 16, in <module>
>    (r'^contact/$',views.contact),
> AttributeError: 'module' object has no attribute 'contact'
>
> Here is urls.py:
>
> from django.conf.urls.defaults import *
> from mysite import views
> from mysite.views import hello, current_datetime, hours_ahead, display_meta
> from django.contrib import admin
> from mysite.contact import views
> from mysite.books import views
>
> admin.autodiscover()
>
> urlpatterns = patterns('',
>        (r'^hello/$', hello),
>        (r'^time/$', current_datetime),
>        (r'^time/plus/(\d{1,2})/$', hours_ahead),
>        (r'^admin/' , include(admin.site.urls)),
>        (r'^contact/$',views.contact),
>        (r'^search-form/$', views.search_form), #from mysite.books
>        (r'^search/$', views.search),           # from mysite.books
>
> )
>
> If I comment out either the reference to importing contact and it's
> pattern or books and it's pattern I get no error. Both books and contact
> are directories at the same level under mysite.
>
> Usually when I get in situations like this it is because I missed
> something.  I've gone back a reviewed everything I have done and still
> don't understand what is wrong.
>
> I would appreciate any help you could give me in figuring this out.
>
> Thanks,  Jim
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@**
> googlegroups.com <django-users%2bunsubscr...@googlegroups.com>.
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
> .
>
>

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

Reply via email to