Generic template; determining information about calling view/app

24 views
Skip to first unread message

David

unread,
May 8, 2015, 12:11:51 PM5/8/15
to django...@googlegroups.com
Hi

Sorry if this is confusing, it's the best I can describe.

I have been separating my templates for inheritance clarity. I have a generic template 'category_list.html'. This can be used by different apps because the layout is the same.

What I need to do in order to use appropriate links in the template is to find out:

a) the name of the application calling it
b) the namespace of the application url so I can use a dynamic {% url %} tag

Firstly, I guess, is this possible?

Yes, I can inherit the templates further and pass info directly from the views, but the creation of extra templates just for these 2 things seemed like I was doing something wrong.

Many thanks for any assistance.

Gergely Polonkai

unread,
May 10, 2015, 12:01:24 PM5/10/15
to django...@googlegroups.com
Hello,

I wrote a middleware[1] for my old blog engine; here, view_func.__module__ is the app’s name. It is not really sophisticated, though, but it may provide a good start.

About the URL namespace, I don’t think it’s easy to do. An app doesn’t have a namespace; you can include an url definition file multiple times with different namespaces.

Best,
Gergely


--
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...@googlegroups.com.
To post to this group, send email to django...@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/64637401-2cbd-4f8c-b7c0-4910aeceeb84%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages