Thank you all for your suggestions.
I did not explain clearly what I was trying to do.
So here's another eg. (with simpler unworkable syntax)

url(add/complete, direct_to_template, template=message.html,
name=add_complete,
  extra_context={
    title:Add Complete,
    url:[reverse(add_item), reverse(view_item), reverse(edit_item)]
}),

url(remove/complete, direct_to_template, template=message.html,
name=remove_complete,
  extra_context={
    title:Remove Complete,
    url:[reverse(remove_item), reverse(list_items)]
}),

So these are pages where you get redirected to, when adding is
complete, removing is complete, etc. and they all look pretty much the
same except with different title and different amount/types of links.

This way there's no need for a new view and a new template. Just
changing a couple of lines in urls.py

But I do realise that reverse(edit_item) and reverse(view_item) won't
work, because there's no ID specified and even so, direct_to_template
won't know what to do with it.

So I ended up creating my own custom view which has reverse,
direct_to_template, and even return json, in it to do what kinda
wanted to do but unfortunately has made many of my apps less portable.
I still need to account for reverse(edit_item) if i wish to have that
in the add complete page.

Anyway that's what I'm trying to do, making coding lazier.

Further suggestions or no, thank you.
Robin

On Apr 3, 10:04 pm, Reiner <[email protected]> wrote:
> I'm not sure if reversing inside theurlpatterns is possible (but I
> kinda doubt it), but maybe I can help out with a different, and
> probably better, solution. It seems you only want to use theURLto
> your add_item_wizard function inside your message.html template. Then
> you could use the builtinurltemplate tag to do the same thing.
>
> For example:
> <a href="{%urladd_item_wizard %}">Link</a>
>
> Look here for more information on this 
> tag:http://docs.djangoproject.com/en/dev/ref/templates/builtins/#url
>
> If you need theURLmultiple times in your template, you can use this
> (as mentioned in the docs):
>
> {%urladd_item_wizard as the_url %}
> <a href="{{ the_url }}">I'm linking to {{ the_url }}</a>
>
> This way you don't need to pass theURLin your extra_context.
>
> Regards,
> Reiner
>
> On Apr 3, 10:24 am, robin <[email protected]> wrote:
>
>
>
> > It seems like you cannot usereversewithin 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?
>
> > Thanks in advance,
> > Robin
--~--~---------~--~----~------------~-------~--~----~
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