Joe
Joe

Reputation: 1772

django templates - include another block from same folder

I'm new to django, I'm trying to figure out how to include other html files from the same subfolder to my main template file.

I've tried the following to no avail:

{% include './_shared.html' %}

I'll eventually have many template folders. Can someone help me out?

Upvotes: 0

Views: 3308

Answers (2)

user1614526
user1614526

Reputation: 474

You have to put your sub folders inside your template directory

You have to define your template path in your settings.py

now you can include that template file like {% include '/yoursubfolder/file.html' %}

Upvotes: 5

tony
tony

Reputation: 1546

Try this:

{% include request.path+"_shared.html" %}

You might have to add slash between path and file name.

Upvotes: 0

Related Questions