On Wed, 2007-02-28 at 05:05 -0800, MattW wrote:
> Dear All,
> 
> I am trying to use the users/ authentication framework supplied with
> Django. I wrote something very simple myself, but would arther use the
> bundled system.
> 
> I have a urls.py file with:
> 
> (r'^login/$',  login),
> (r'^logout/$', logout),
> 
> in (I know these are different to the ones given in the examples)
> 
> I have created a template, registration/login which contains the
> template code from the Django book.
> 
> But when I point to browser to localhost:8000/login I get an error:
> 
> AttributeError at /login/
> 'function' object has no attribute 'rindex'
> Request Method:       GET
> Request URL:  http://localhost:8000/login/
> Exception Type:       AttributeError
> Exception Value:      'function' object has no attribute 'rindex'
> Exception Location:   /usr/lib/python2.4/site-packages/Django-0.95-
> py2.4.egg/django/core/urlresolvers.py in get_mod_func, line 23
> Traceback (innermost last)
> Switch back to interactive view
> 
> and a long stack trace.
> 
> Any ideas?

Looks like you are using a vanilla Django 0.95 release, whereas the code
in the Django book is written against the subversion code. The
difference in this case is that URL resolving can now (post-0.95) happen
against function objects, not just strings. 

In 0.95, you would need to write your URL patterns as

        (r'^login/$',  'path.to.login')

Note that the function name to call is now a string in dotted Python
notation, not a reference to the function itself.

You might want to have a quick read through
http://www.djangoproject.com/documentation/url_dispatch/ to see what is
going on here. Notice how all the early examples there use strings as
the function names to call. Only in
http://www.djangoproject.com/documentation/url_dispatch/#passing-callable-objects-instead-of-strings
 is the concept of using function references directly mentioned (and it's 
marked as "new in development version").

The problem Adrian and Jacob have with writing a book like that is that
the dead tree version will be released sometime in the future, so you
have to write a bit ahead of what is available in the last release.

Regards,
Malcolm



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

Reply via email to