Django Templates — 18 Operations for AI Agents
Django templates are where server-rendered Python apps meet HTML: blocks, inheritance chains, template tags. act101 navigates that inheritance structurally, so agents find which block actually renders without opening every parent template.
This page is the canonical reference an AI coding agent uses to refactor, query, and analyze Django Templates code through the act MCP server. 18 operations available: 0 refactor, 18 query, 0 analysis. Each operation is callable from Claude Code, Cursor, Codex, OpenCode, or any MCP-compatible agent host. Click any operation for a stable anchor link suitable for citation.
Worked Django Templates examples
act101 reads a Django template's {% extends %} tag as an import declaration, its {% include %} tag as an include declaration, and each {% block %}/{% endblock %} pair as a block declaration named for the block's identifier. symbols narrows that set to just the {% block %} definitions, reported as kind unknown rather than block, since the query's bare @definition capture has no kind suffix to draw from; the extends and include tags carry no rule in symbols.scm and never appear there. The unit of structure in this grammar is the template tag: a template built from nested {% for %}/{% if %} control flow reports nothing for the loops or conditionals themselves, only the block/extends/include tags that sit inside or around them. Each example below is the verbatim output of the command shown, run against the file shown. Query outputs are pretty-printed with the timing block omitted.
Read the template's inheritance tag and named blocks
docket.djhtml extends a shared docket/base.html layout and defines three named blocks — docket_header, docket_body, and docket_footer — with a {% for %}/{% include %} pair inside docket_body rendering each case row.
$ act query skeleton docket.djhtml
Before
{% extends "docket/base.html" %}
{% block docket_header %}
<h1>{{ courtroom.name }} — {{ hearing_date }}</h1>
{% endblock %}
{% block docket_body %}
<table class="docket">
{% for case in cases %}
{% include "docket/case_row.html" %}
{% endfor %}
</table>
{% if recess %}
<p class="recess-notice">Court in recess until {{ recess.resume_time }}</p>
{% endif %}
{% endblock %}
{% block docket_footer %}
<p class="clerk">Clerk of court: {{ clerk_name }}</p>
{% endblock %}
Output
{
"type": "Skeleton",
"declarations": [
{
"kind": "import",
"name": "\"docket/base.html\"",
"range": {
"start": {
"file": "docket.djhtml",
"line": 1,
"column": 4,
"byte_offset": 3
},
"end": {
"file": "docket.djhtml",
"line": 1,
"column": 30,
"byte_offset": 29
}
},
"name_range": {
"start": {
"file": "docket.djhtml",
"line": 1,
"column": 12,
"byte_offset": 11
},
"end": {
"file": "docket.djhtml",
"line": 1,
"column": 30,
"byte_offset": 29
}
}
},
{
"kind": "block",
"name": "docket_header",
"range": {
"start": {
"file": "docket.djhtml",
"line": 3,
"column": 4,
"byte_offset": 37
},
"end": {
"file": "docket.djhtml",
"line": 3,
"column": 23,
"byte_offset": 56
}
},
"name_range": {
"start": {
"file": "docket.djhtml",
"line": 3,
"column": 10,
"byte_offset": 43
},
"end": {
"file": "docket.djhtml",
"line": 3,
"column": 23,
"byte_offset": 56
}
}
},
{
"kind": "block",
"name": "docket_body",
"range": {
"start": {
"file": "docket.djhtml",
"line": 7,
"column": 4,
"byte_offset": 134
},
"end": {
"file": "docket.djhtml",
"line": 7,
"column": 21,
"byte_offset": 151
}
},
"name_range": {
"start": {
"file": "docket.djhtml",
"line": 7,
"column": 10,
"byte_offset": 140
},
"end": {
"file": "docket.djhtml",
"line": 7,
"column": 21,
"byte_offset": 151
}
}
},
{
"kind": "include",
"name": "include \"docket/case_row.html\"",
"range": {
"start": {
"file": "docket.djhtml",
"line": 10,
"column": 10,
"byte_offset": 217
},
"end": {
"file": "docket.djhtml",
"line": 10,
"column": 40,
"byte_offset": 247
}
}
},
{
"kind": "block",
"name": "docket_footer",
"range": {
"start": {
"file": "docket.djhtml",
"line": 18,
"column": 4,
"byte_offset": 410
},
"end": {
"file": "docket.djhtml",
"line": 18,
"column": 23,
"byte_offset": 429
}
},
"name_range": {
"start": {
"file": "docket.djhtml",
"line": 18,
"column": 10,
"byte_offset": 416
},
"end": {
"file": "docket.djhtml",
"line": 18,
"column": 23,
"byte_offset": 429
}
}
}
]
}
The skeleton reports five declarations: the {% extends %} tag as import (keeping its quoted string "docket/base.html"), the three {% block %} tags as block, and the {% include %} tag as include; the {% for %} and {% if %} tags around them produce nothing.
List the named blocks as symbols
docket_header, docket_body, and docket_footer are the same three blocks the skeleton reported.
$ act query symbols docket.djhtml
Before
{% extends "docket/base.html" %}
{% block docket_header %}
<h1>{{ courtroom.name }} — {{ hearing_date }}</h1>
{% endblock %}
{% block docket_body %}
<table class="docket">
{% for case in cases %}
{% include "docket/case_row.html" %}
{% endfor %}
</table>
{% if recess %}
<p class="recess-notice">Court in recess until {{ recess.resume_time }}</p>
{% endif %}
{% endblock %}
{% block docket_footer %}
<p class="clerk">Clerk of court: {{ clerk_name }}</p>
{% endblock %}
Output
{
"type": "Symbols",
"symbols": [
{
"name": "docket_header",
"kind": "unknown",
"range": {
"start": {
"file": "docket.djhtml",
"line": 3,
"column": 10,
"byte_offset": 43
},
"end": {
"file": "docket.djhtml",
"line": 3,
"column": 23,
"byte_offset": 56
}
},
"visibility": "unknown"
},
{
"name": "docket_body",
"kind": "unknown",
"range": {
"start": {
"file": "docket.djhtml",
"line": 7,
"column": 10,
"byte_offset": 140
},
"end": {
"file": "docket.djhtml",
"line": 7,
"column": 21,
"byte_offset": 151
}
},
"visibility": "unknown"
},
{
"name": "docket_footer",
"kind": "unknown",
"range": {
"start": {
"file": "docket.djhtml",
"line": 18,
"column": 10,
"byte_offset": 416
},
"end": {
"file": "docket.djhtml",
"line": 18,
"column": 23,
"byte_offset": 429
}
},
"visibility": "unknown"
}
]
}
symbols reports only these three block declarations, and every one comes back kind unknown rather than block; the {% extends %} and {% include %} tags that appeared in the skeleton are absent, since symbols.scm has no rule for either.
Query
18 query tools, the same on every supported language. Descriptions live in the shared reference: /docs/query-tools.
callers control_flow data_flow definition diagnostics effect_closure effect_summary fix_auto get_type graph import_organize interface mutations references repo_outline skeleton symbols symbols_batch