django book chpt. 3 bug?

1 view
Skip to first unread message

walterbyrd

unread,
Jun 18, 2007, 10:57:54 PM6/18/07
to Django users
I believe this is a bug, and I think it's been reported. I think it
was also reported as fixed, but I don't think it is fixed.

When I try to run the example program, I get a page full of errors,
with this heading:

---
AttributeError at /now/
'function' object has no attribute 'rindex'
Request Method: GET
Request URL: http://127.0.0.1:8000/now/
Exception Type: AttributeError
Exception Value: 'function' object has no attribute 'rindex'
Exception Location: /var/lib/python-support/python2.4/django/core/
urlresolvers.py in get_mod_func, line 23
---

The problem seems t be in line 23 of urlresolvers.py.

---
23 dot = callback.rindex('.')
---

Apparently, there is some problem with the "rindex" attribute.

I am brand new to Django. I have no idea what to do about this. Is
this a bug? Or did I do something wrong?

walterbyrd

unread,
Jun 18, 2007, 11:16:56 PM6/18/07
to Django users
Googling around some more, I managed to get it to work. But, I still
don't think it's right. According to this site:

http://notkeepingitreal.com/articles/category/django

According to the blog on that site, parameter in urls.py needs to be
changed from:

(r'^now/$', current_datetime),

To:

(r'^now/$', 'survey.views.current_datetime'),

I tried that, and it still didn't work. Then I changed the parameter
to:

(r'^now/$', 'views.current_datetime'),

And it worked.

The blog on that site was written last January. Numerous other errors
were cited. If these are known problems, that have been around that
long, that's pretty bad.

JMHO.

Jeremy Dunck

unread,
Jun 18, 2007, 11:21:54 PM6/18/07
to django...@googlegroups.com
On 6/18/07, walterbyrd <walte...@iname.com> wrote:
>
...

> AttributeError at /now/
> 'function' object has no attribute 'rindex'

I think you're using an old version of Django. The latest stable is
0.96. Please update to that.

Jeremy Dunck

unread,
Jun 18, 2007, 11:23:14 PM6/18/07
to django...@googlegroups.com
On 6/18/07, walterbyrd <walte...@iname.com> wrote:
...
> (r'^now/$', 'survey.views.current_datetime'),

That's only necessary due to the old Django version.

> I tried that, and it still didn't work. Then I changed the parameter
> to:
>
> (r'^now/$', 'views.current_datetime'),

This is due to your local python path. The string given there is an
import path, and if you can't import 'survey' from regular python,
Django won't be able to either. Consider adding the parent directory
of 'survey' to your python path.

Reply all
Reply to author
Forward
0 new messages