First Template¶
Build a small Django template that replaces a result area with an HTMX response and defines a local partial.
Prerequisites¶
- The file language mode is Django HTML.
- The Django URL named
catalog:resultsexists in your project.
Template¶
<button
hx-get="{% url 'catalog:results' %}"
hx-target="#results"
hx-swap="innerHTML">
Load results
</button>
<section id="results">
{% partialdef result_card inline %}
<article id="result-{{ result.pk }}">{{ result.title }}</article>
{% endpartialdef %}
</section>
{% partial result_card %}
The extension completes hx-* attributes and documented values such as innerHTML. In a {% partial tag, it offers definitions from the same template and reports unknown or duplicate local partial names.
Verify¶
- Place the cursor after
hx-and request completion. - Place it inside
hx-swap=""and request completion. - Hover
result_cardin{% partial result_card %}. - Change the reference to a missing name and confirm a diagnostic appears.
Same-file scope
Cross-template references such as template.html#result_card are resolved from matching workspace files on demand; Django loader order is not modeled.