Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4012582
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:15:55+00:00 2026-05-20T09:15:55+00:00

Is the parsing order for Django templates specified somewhere in the Django documentation? Based

  • 0

Is the parsing order for Django templates specified somewhere in the Django documentation?

Based on the documentation for writing custom template tags and the API, it seems Django uses a depth-first traversal for building the node tree. However, I can’t find any statement in the Django documentation that guarantees this. In particular, I’d like to know if the node tree is completely assembled before any rendering is done.

Also, how does this affect template inheritance? Are the {% block ... %} tags in the derived template parsed at their location in the base template or are they parsed by the {% extends "..." %} tag before the base template?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:15:56+00:00Added an answer on May 20, 2026 at 9:15 am

    The answer is yes, all nodes are created when you create a Template object. But the magic happens when you call the render method of this object. This Template object has a NodeList with it that is rendered within a context. This rendering is done as you said before, depth first, and it just gets the inners child strings (html) appended to the father Node. Here is the NodeList class where the node rendering is done. So, the root node is the one to get all the nodes appended to it to finally generate the file. And if you remember, the extends template tag must be first in the template so it becomes the root node who get all the already rendered nodes in it.

    Now, what about inheritance? How is the exteds root node rendered? Well, I haven’t figured out all about the context role here, but there is a ExtendsNode that is created by the extends template tag. This type of node recieves the parent template name (your base template) and a context with all the variables, blocks and nodes of the child template (the one you actually call to render). So when this node is rendered, it does the same thing that every node does, append his child nodes. The main difference in this class is that it gets the nodes marked with the block template tag from the child’s template context, and appends it everywhere you defined a block template tag with that name in the parent template.

    So the nodes are created first, and the extends template tag manage to get them when you render the template.

    If you want to know how nodes a created, you can look for the Token and Parser class at the Django code.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking at parsing a delimited string, something on the order of a,b,c But
Regex.IsMatch( foo, [\U00010000-\U0010FFFF] ) Throws: System.ArgumentException: parsing [-] - [x-y] range in reverse order.
In my Django project I am using Product.objects.all().order_by('order') in a view, but it doesn't
I need to have correct order of values inside Ruby array after parsing YAML
I am parsing some enum values from a text file. In order to simplify
In order to work with some client information I have been parsing a 3MB
I've a parsing issue using Drupal tokens : [order-shipping-phone] [order-billing-address] However there are not
The divs below appear in that order in the HTML I am parsing. //div[contains(@class,'top-container')]//font/text()
Parsing a text file in vb.net and need to locate the latitude and longitude
For parsing player commands, I've most often used the split method to split a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.