0

In my Django, is there a way to reuse HTML blocks from different sources? I know that there is a way to inherit HTML from a base template but what is there a way to get HTML from two or more sources?

Let's say that I wanted to grab a template that only contains a table and another template that only contains a navigation bar and place that on top of the base HTML. How would I go about doing that? Let's also make the assumption that template with the table and the template with the navigation bar has variable tags like {{variable}}.

Thanks in advance!

EDIT: Grammar.

1 Answer 1

2

I think you can just use {% include "path/to/partial.html" %} to achieve this.

One example from Django document:

{% include "name_snippet.html" with person="Jane" greeting="Hello" %}

Reference: https://docs.djangoproject.com/en/1.9/ref/templates/builtins/#include

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Exactly what I am looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.