Error

0 views
Skip to first unread message

pranjal

unread,
Dec 26, 2009, 6:24:30 AM12/26/09
to Django users
I had an error using django.Versions : Django 1.1.1, Python 2.6.4
In the views file when I passed the argument as a string there is an
error
Error: 'str' object not callable.

This shouts : 'str' object not callable
urlpatterns = patterns('',
(r'^first/$','firstsite'),

This works fine :

urlpatterns = patterns('',
(r'^first/$',firstsite),

Łukasz Balcerzak

unread,
Dec 26, 2009, 6:56:33 AM12/26/09
to django...@googlegroups.com
Hi,

First argument in ``patterns`` factory method is like the starting point
for all views that should be called. Moreover, you may pass function view
as a callable object or as a string but in this case your starting point
has to be hooked first.

So, if for instance, your view method 'firstsite' is in module 'mysite.views'
you have to pass full module-path here ('mysite.views.firstsite') or hook 'mysite.views'
as starting point (first argument of patterns method). Like that:

> urlpatterns = patterns('mysite.views',


> (r'^first/$','firstsite'),

or if you don't want to specify starting point:

> urlpatterns = patterns('',
> (r'^first/$','mysite.views.firstsite'),


Hope it helps

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

Reply all
Reply to author
Forward
0 new messages