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.) 回答1: There's a way to obtain an app name for a current request. First, in your project's urls.py, considering your app is called 'main' : #urls.py url(r'^', include('main.urls', app_name="main")), Then, a context