Django template how to re-use a template html file twice -


i have 3 files:

  1. base.html
  2. results.html extends base.html
  3. 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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -