4

I have three html-files:

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

in page.html I extend base.html. In comment.html I extend page.html. Will comment.html extend base.html's blocks?

Ram Rachum
  • 84,019
  • 84
  • 236
  • 374
megido
  • 4,135
  • 6
  • 29
  • 33
  • As i know , there is not multiple inheritance, its only simple or multi-level inheritance as Daniel Roseman says. – ecdani Apr 01 '13 at 20:09

2 Answers2

10

Yes, you can actually use as many levels of inheritance as you'd like. From The Django Book:

One common way of using inheritance is the following three-level approach:

(1) Create a base.html template that holds the main look-and-feel of your site. This is the stuff that rarely, if ever, changes.

(2) Create a base_SECTION.html template for each “section” of your site. For example, base_photos.html, base_forum.html. These templates all extend base.html and include section-specific styles/design.

(3) Create individual templates for each type of page, such as a forum page or a photo gallery. These templates extend the appropriate section template.

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

Community
  • 1
  • 1
rolling stone
  • 12,668
  • 9
  • 45
  • 63
7

Yes, it will. Why not to try it yourself?

DrTyrsa
  • 31,014
  • 7
  • 86
  • 86