Is it possible to do multi-level template inheritance in django templates?

I have three html files:

  • base.html
  • page.html
  • comment.html

in page.html I am extending base.html . In comment.html, I am expanding page.html . Will comment.html extend base.html blocks?

+3
source share
2 answers

Yes it will. Why not try it yourself?

+5
source

Yes, you can use as many levels of inheritance as you want. From the book of Django:

One common way to use inheritance is with the following three-tier approach:

(1) base.html, . , , -, .

(2) base_SECTION.html "" . , base_photos.html, base_forum.html. base.html / .

(3) , , . .

: http://www.djangobook.com/en/2.0/chapter04.html

+9

All Articles