title: Django Override Admin change_form.html Template - display associated model in template
body: <p>I have a situation where I've overrided the admin_change.html template for a given model.  I've created a file such as:</p>
  
  <pre><code>/myproject/templates/admin/myapp/mymodel/change_form.html
  </code></pre>
  
  <p>Then, in the overrided change_form.html template, where I am editing an existing object instance, I want to have access to that model instance variable so I can display more information about it.  </p>
  
  <pre><code>{% extends "admin/change_form.html" %}
  {% block after_field_sets %}{{ block.super }}
  Print my model here: {{ mymodel }}
  Print foreignkey related records of my model:  
      {% for item in mymodel.items_set.all %} {{ item }} {% endfor %}
  {% endblock %}
  </code></pre>
  
  <p>However, I don't know what the template variable is called that I should use to access this model (if it is even passed at all).  I've tried digging through the admin source code, but get lost quickly.  Does anyone know how to access this model instance variable from within an extended django template? </p>
  
  <p>(NOTE: in the above code, the reference to {{ mymodel }} is incorrect.  But the point is that I want to be able to use a variable like that in my template code to reference the mymodel instance.)</p>
  
  <p>Any advice is much appreciated.
  Thanks,
  Joe</p>