On Sat, 2007-11-10 at 10:25 +0000, [EMAIL PROTECTED] wrote:
> > hello,
> >
> > I am learning a lot from the B-List blog
> > Here is an entry, which could be interesting for 
> > you:http://www.b-list.org/weblog/2007/nov/06/urlconf/
> > (specially the named URL patterns)
> 
> Thanks Bernd,
> 
> I'd seen that before, and decided I wouldn't mess with it if I
> couldn't get the basics to work. But I just tried it, and turning
> (r'^$', 'index'),
> into
> (r'^$', 'index', name="blog-index"),
> 
> gave me a syntax error on that line. I'm running r6659, only one short
> of head. Is it because I'm not using generic views? I wonder if this
> is another indication of whatever it is I've borked...

No. This one's a case or pilot error. If you want to use this form, you
must write it as:

        url(r'^$', 'index', name="blog-index")
        
url() is a function call, so you can pass it named arguments. The (...)
form (without a leading "url") is a Python tuple and you can't use
'name=value' style arguments and it must have four arguments. Best to
stick to the url() form.

By the way, you can test whether things are working at the interactive
prompt using reverse(), which is how the url template tag is
implemented:

        >>> from django.core.urlresolvers import reverse
        >>> reverse('index')
        u'/'
        
would be what I would expect to see here. If you want to pass arguments
to reverse(), use the 'args' and 'kwargs' named parameters (the second
positional argument is something different).

Malcolm

-- 
Depression is merely anger without enthusiasm. 
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to