0👍
✅
What I’ve finally done was using url from future
as @lalo suggested, and adding both app and instance namespacing to my urls.py
urlpatterns = patterns('',
url(r'^canvas/', include('canvas.urls', app_name="myapp", namespace="canvas")),
url(r'^checkin/', include('checkin.urls', app_name="myapp", namespace="checkin")),
url(r'^show/', include('facebook_tab.urls', app_name="myapp", namespace="facebook_tab")),
Then, from my views I set my current_app as:
return render(request, self.template_name, context, current_app="canvas")
And from my generic template:
{% load url from future %}
{% url 'myapp:shows'%}
That last url would resolve to 'canvas:shows'
or 'facebook_tab:shows'
depending on the namespace set on current_app
.
I read the official docs and I don’t already get the difference between application namespace and instance namespace clearly, but I managed to get it to work.
2👍
Importing url
from future in your template should work:
#At the top of the template
{% load url from future %}
#Somewhere in your template
{% url "canvas:shows" %}.
See here:
https://docs.djangoproject.com/en/1.4/topics/http/urls/#url-namespaces
and
https://docs.djangoproject.com/en/1.4/ref/templates/builtins/#url
- [Answered ]-Does Django pick template changes when DEBUG=False? Yes, but HOW?
- [Answered ]-Django object filtering with variables
- [Answered ]-I have a list of long integers that I assign to a django model charfield. The list of longs get converted to list of unicodes
- [Answered ]-Django makemigrations error non-nullable field
Source:stackexchange.com