Friday, January 30, 2015

Re: Namespace url lookup inside template of an app

Answering my own question, for the case someone else need it:

I am used to use render_to_response it not working with it, with using
render it works with applying current_app, like this:

return render(request, 'myaddons/index.html',
{'addons':addons,'game':game,},current_app=request.resolver_match.namespace)

Am 29.01.2015 um 21:24 schrieb Thorsten Sanders:
> Hello,
>
> writing currently an app which should show different things based on
> namespace which is working already, but I do have problems with
> generating the right url inside the templates of that app.
> I tried to use:
> {% url 'myaddons:index' %}
> but that always shows the same namespace url the last one attached.
>
> Currently have defined inside that app:
> urlpatterns = patterns('',
> url(r'^$', 'myaddons.views.index', name='index'),
> )
>
> Then have 2 other apps in one I define:
> urlpatterns = patterns('',
> url(r'^addons/', include('myaddons.urls',
> namespace='wow-myaddons', app_name='myaddons')),
> )
>
> in the other one:
> urlpatterns = patterns('',
> url(r'^addons/', include('myaddons.urls', namespace='ws-myaddons',
> app_name='myaddons')),
> )
>
> The base one is:
>
> url(r'^wow/', include('warcraft.urls')),
> url(r'^ws/', include('wildstar.urls')),
>
> With what I tried it always resolve to:
> /ws/addons/
>
> I want it to resolve to:
> /wow/addons/ if called with /wow/
> and
> /ws/addons/ if called with /ws/
>
> Greetings,
> Thorsten
>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/54CB8061.4060904%40gmx.net.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment