Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django - extend template from parent directory

I have this templates structure:

dir1: base.html dir2: template.html

template.html must extend base.html:

{% extends '../dir1/base.html' %}

But it raises error:

Caught TemplateDoesNotExist while rendering: ../dir1/base.html

like image 973
artem Avatar asked Feb 23 '26 15:02

artem


1 Answers

You should set template dir (https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs) in settings.py and then use {% extends 'dir/base.html' %}.

like image 135
gruszczy Avatar answered Feb 25 '26 07:02

gruszczy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!