title: Django: How can I identify the calling view from a template?
body: <p><strong>Short version:</strong></p>
  
  <p>Is there a simple, built-in way to identify the calling view in a Django template, without passing extra context variables?</p>
  
  <p><strong>Long (original) version:</strong></p>
  
  <p>One of my Django apps has several different views, each with its own named URL pattern, that all render the same template. There's a very small amount of template code that needs to change depending on the called view, too small to be worth the overhead of setting up separate templates for each view, so ideally I need to find a way to identify the calling view in the template.</p>
  
  <p>I've tried setting up the views to pass in extra context variables (e.g. "view_name") to identify the calling view, and I've also tried using <code>{% ifequal request.path "/some/path/" %}</code> comparisons, but neither of these solutions seems particularly elegant. Is there a better way to identify the calling view from the template? Is there a way to access to the view's name, or the name of the URL pattern?</p>
  
  <hr>
  
  <p><strong>Update 1:</strong> Regarding the comment that this is simply a case of me misunderstanding MVC, I understand MVC, but <a href="http://docs.djangoproject.com/en/dev/faq/general/#django-appears-to-be-a-mvc-framework-but-you-call-the-controller-the-view-and-the-view-the-template-how-come-you-don-t-use-the-standard-names" rel="noreferrer">Django's not really an MVC framework</a>. I believe the way my app is set up is consistent with Django's take on MVC: the views describe <em>which</em> data is presented, and the templates describe <em>how</em> the data is presented. It just happens that I have a number of views that prepare different data, but that all use the same template because the data is presented the same way for all the views. I'm just looking for a simple way to identify the calling view from the template, if this exists.</p>
  
  <p><strong>Update 2:</strong> Thanks for all the answers. I think the question is being overthought -- as mentioned in my original question, I've already considered and tried all of the suggested solutions -- so I've distilled it down to a "short version" now at the top of the question. And right now it seems that if someone were to simply post "No", it'd be the most correct answer :)</p>
  
  <p><strong>Update 3:</strong> Carl Meyer posted "No" :) Thanks again, everyone.</p>