Re: url tag difficulties

2007-11-10 Thread Malcolm Tredinnick


On Sat, 2007-11-10 at 11:02 +, [EMAIL PROTECTED] wrote:
> > 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:
> 
> Thanks you two, I hadn't caught on that it was going from a tuple to
> an actual function.
> 
> reverse('index') gets me NoReverseMatch, which isn't surprising given
> that my urls aren't working. I'm going to do some tidying and make
> sure nothing's escaped me.

I would suggest commenting out every line from your urlpatterns except
the one you are debugging. That way you won't be accidentally sabotaged
by a problem elsewhere.

As has been pointed out here recently, URL configuration either works or
it doesn't: if you have a bug somewhere, such as a non-existent view,
the whole thing falls over. That will be fixed tomorrow, probably -- I'm
going to sit down and spend a day closing bugs and that's on my list.

Malcolm

-- 
Many are called, few volunteer. 
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
-~--~~~~--~~--~--~---



Re: url tag difficulties

2007-11-10 Thread girzel

> 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:

Thanks you two, I hadn't caught on that it was going from a tuple to
an actual function.

reverse('index') gets me NoReverseMatch, which isn't surprising given
that my urls aren't working. I'm going to do some tidying and make
sure nothing's escaped me.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: url tag difficulties

2007-11-10 Thread Malcolm Tredinnick


On Sat, 2007-11-10 at 10:25 +, [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
-~--~~~~--~~--~--~---



Re: url tag difficulties

2007-11-10 Thread Jonathan Buchanan

[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...
> 
> E

That should be:

url(r'^$', 'index', name="blog-index"),

Jonathan.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: url tag difficulties

2007-11-10 Thread girzel

> 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...

E


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: url tag difficulties

2007-11-10 Thread Brot

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)

Bernd

On Nov 10, 5:53 am, "Todd O'Bryan" <[EMAIL PROTECTED]> wrote:
> I've also been a little frustrated with the {% url %} tag. It's very
> easy to mess it up, and very hard to figure out what's messed up. I
> wonder if we couldn't provide some debugging information if DEBUG is
> set to true.
>
> Todd
>
> On Nov 9, 2007 10:54 PM,  <[EMAIL PROTECTED]> wrote:
>
>
>
> > I really hope this isn't embarrassingly obvious but...
>
> > My {% url %} tags aren't producing anything -- no error and no url. My
> > current setup is so bare-bones I can't imagine what's gone wrong. Here
> > are the basics:
>
> > ROOT_URLCONF = Project.urls
>
> > In Project.urls:
> > (r'^$', 'app1.views.index'),
> > (r'^(?Pauthors|books|publishers)/$', 'app2.views.browse'),
>
> > The app2.views.browse view uses a render_to_response, with a
> > RequestContext. I've got no TEMPLATE_CONTEXT_PROCESSORS set, so I'm
> > using default.
>
> > app2.views.browse renders the app2/browse.html template, with no
> > context variables passed in except what the RequestContext puts in
> > there. I thought the problem was that ROOT_URLCONF wasn't available in
> > the template, but I imported that specifically and passed it in, with
> > the same result.
>
> > In app2/browse.html template:
> > Home
> > (I've also tried Project.app1.views.index, and other variations, with
> > the same result)
>
> > All I want is a link to the homepage, but nothing is output. This is
> > the simplest case but the I get the same result in all my views and
> > templates. I'm using the development version of Django, and the
> > development server.
>
> > Can anyone see where I've got wrong? I tried setting the
> > TEMPLATE_STRING_IF_INVALID variable to '%s', but I guess this doesn't
> > actually count as an invalid template tag.
>
> > I'd be very grateful for any help!
>
> > Eric


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: url tag difficulties

2007-11-09 Thread Todd O'Bryan

I've also been a little frustrated with the {% url %} tag. It's very
easy to mess it up, and very hard to figure out what's messed up. I
wonder if we couldn't provide some debugging information if DEBUG is
set to true.

Todd

On Nov 9, 2007 10:54 PM,  <[EMAIL PROTECTED]> wrote:
>
> I really hope this isn't embarrassingly obvious but...
>
> My {% url %} tags aren't producing anything -- no error and no url. My
> current setup is so bare-bones I can't imagine what's gone wrong. Here
> are the basics:
>
> ROOT_URLCONF = Project.urls
>
> In Project.urls:
> (r'^$', 'app1.views.index'),
> (r'^(?Pauthors|books|publishers)/$', 'app2.views.browse'),
>
> The app2.views.browse view uses a render_to_response, with a
> RequestContext. I've got no TEMPLATE_CONTEXT_PROCESSORS set, so I'm
> using default.
>
> app2.views.browse renders the app2/browse.html template, with no
> context variables passed in except what the RequestContext puts in
> there. I thought the problem was that ROOT_URLCONF wasn't available in
> the template, but I imported that specifically and passed it in, with
> the same result.
>
> In app2/browse.html template:
> Home
> (I've also tried Project.app1.views.index, and other variations, with
> the same result)
>
> All I want is a link to the homepage, but nothing is output. This is
> the simplest case but the I get the same result in all my views and
> templates. I'm using the development version of Django, and the
> development server.
>
> Can anyone see where I've got wrong? I tried setting the
> TEMPLATE_STRING_IF_INVALID variable to '%s', but I guess this doesn't
> actually count as an invalid template tag.
>
> I'd be very grateful for any help!
>
> Eric
>
>
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---