[Fixed]-Django Override Admin change_form.html Template – display associated model in template

21👍

Looks like I found a means to do this using this syntax.

{% extends "admin/change_form.html" %}
{% block after_field_sets %}{{ block.super }}
Print my model here {{ original }}
Print foreignkey related records of my model:
{% for item in original.items_set.all %} {{ item }} {% endfor %}
{% endblock %}

Sorry to answer so soon, but thanks to anyone who started researching. Perhaps someone will find this helpful. If you see a better way to do this, feel free to comment.

👤Joe J

19👍

Just poking around, it seems that {{adminform.form.instance}} works.

👤fooo

Leave a comment