Re: reverse( ) and template tag 'url' fail when pattern has include

2008-02-13 Thread grahamu
On Feb 14, 12:04 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > That's because you are expecting things from reverse() that it > explicitly doesn't do. In particular, the "args" and "kwargs" parameters > to reverse are only checked against capturing groups in the URL's > regular expression.

Re: reverse( ) and template tag 'url' fail when pattern has include

2008-02-13 Thread Malcolm Tredinnick
On Wed, 2008-02-13 at 22:35 -0800, grahamu wrote: > > On Feb 13, 7:15 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> > wrote: > [...] > > As Alex pointed out, you're calling reverse() on something that isn't a > > direct URL pattern. Don't do that. It makes no sense to call reverse() > > on somethin

Re: reverse( ) and template tag 'url' fail when pattern has include

2008-02-13 Thread grahamu
On Feb 13, 7:15 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: [...] > As Alex pointed out, you're calling reverse() on something that isn't a > direct URL pattern. Don't do that. It makes no sense to call reverse() > on something that is actually a collection of URL patterns. Instead, > pick

Re: reverse( ) and template tag 'url' fail when pattern has include

2008-02-13 Thread Malcolm Tredinnick
On Wed, 2008-02-13 at 15:22 -0800, grahamu wrote: [...] > >>> reverse('eat') > Traceback (most recent call last): [...] > NoReverseMatch > > Is there a workaround for this issue? Am I doing something > incorrectly? As Alex pointed out, you're calling reverse() on something that isn't a direct U

Re: reverse( ) and template tag 'url' fail when pattern has include

2008-02-13 Thread Dj Gilcrease
Try writing your urls like this urlpatterns = patterns('', url(r'^drink/', 'views.func', kwargs={'myname':'drink'}, name='drink'), url(r'^eat/', 'views.func', kwargs={'myname':'eat'}, name='eat'), url(r'^exercise/', 'views.func', kwargs={'myname':'exercise'}, name='exercise'), url(r'^s

Re: reverse( ) and template tag 'url' fail when pattern has include

2008-02-13 Thread grahamu
Thanks for your explanation, Alex. Unfortunately, "reverse('views.func')" always returns the first match for that function in urlpatterns. My objective is to distinguish between two different URL patterns which both resolve to the same view function. Given your suggestion, I tried the following:

Re: reverse( ) and template tag 'url' fail when pattern has include

2008-02-13 Thread Alex Koshelev
Hi, graham Imagine that your urls2.py has some number of patterns. And then you call `reverse('eat')` what of them have to be returned? So to get proper result you have to write something like this `reverse('views.func')` On 14 фев, 02:22, grahamu <[EMAIL PROTECTED]> wrote: > Lots of people corr

reverse( ) and template tag 'url' fail when pattern has include

2008-02-13 Thread grahamu
Lots of people correctly suggest using named url patterns and the {% url %} template tag to obtain a URL. The concept is great and follows the DRY principle. However, I believe that if a pattern has an "include()" instead of a view function, the existing mechanism fails. An example of the problem,