Django template how to re-use a template html file twice -
i have 3 files:
- base.html
- results.html extends base.html
- results_only.html (standalone)
results_only.html
called ajax , returned <tr>
fields only. <tr>
lines duplicated in results.html
currently, i'd rather have them not duplicated.
how can "import" results_only.html
results.html
... like:
file results.html
:
{% extends "base.html" %} {% block header%}...{% endblock%} {% block content} <div>results are:</div> <table> <tbody> {% import "results_only.html" %} </tbody> </table> {% endblock %}
i'd rather not duplicate the contents of results_only.html
in 2 places.
hope question clear.
https://docs.djangoproject.com/en/dev/ref/templates/builtins/#include
{% include "results_only.html" %}
i think clear :)
Comments
Post a Comment