On Fri, Apr 3, 2009 at 9:03 PM, Malcolm Tredinnick <[email protected]
> wrote:
>
> On Fri, 2009-04-03 at 01:24 -0700, robin wrote:
> > It seems like you cannot use reverse within urls.py
> >
> > url(r'^add/$','items.views.add_item_wizard',name='add_item_wizard'),
> >
> > url(r'^add/complete/
> > $','django.views.generic.simple.direct_to_template',{
> > 'template':'message.html',
> > 'extra_context':{
> > 'title': 'Add Item Complete',
> > 'url': reverse('add_item_wizard'),
> > }
> > }, name='add_item_complete'),
> >
> > Is there no way?
>
> Somebody has already posted a better solution to this, but I'll confirm
> that this is indeed not possible. Partly for implementation reasons (the
> reverse resolver needs to know about all the urlpatterns before it can
> work, which cannot happen during import, since they haven't been
> imported yet).
>
> One day we might add a lazy_reverse that works like this, but that's
> some way off into the future. There's pretty much always a workaround or
> better solution.
>
> Regards,
> Malcolm
>
>
>
> >
>
A lazy reverse shouldn't be too difficult to implement in your own code
though:
from django.utils.functional import lazy
reverse_lazy = lazy(reverse, str)
This is totally untested,
Alex
--
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---