How to get the name of current app within a template?

What's the simplest way to access the name of the current app within template code?

Alternatively, what's the simplest way to define a template variable to hold the name of the current app?

(The goal here is to minimize the number of places I need to edit if I rename an app.)


There's a way to obtain an app name for a current request. First, in your project's, considering your app is called 'main':
url(r'^', include('main.urls', app_name="main")),

Then, a context processsor:

from django.core.urlresolvers import resolve
def appname(request):
    return {'appname': resolve(request.path).app_name}

Don't forget to enable it in your settings:

You can use it in your template like any other variable: {{ appname }}.

Need Your Help

Do too many plug-ins slow down Eclipse?

java eclipse ide eclipse-plugin performance

I have recently installed a new project into my Eclipse and also needed to install some plug-ins to manage it. I also installed other plug-ins which I do not need to manage the project but thought it

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.