O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

27.3.4 Listing the Latest Blog Posts

When we want to build a more complicated template tag, Django cannot provide a decorator to make our life easier. Instead, we must deal with the objects that Django uses internally.

For a template tag, Django expects the creation of a function and a subclass of the Node class. The function we create can be thought of loosely as a function to lex and parse the call to the template tag. The Node subclass is what Django uses in the abstract syntax list (yes, that’s right—it is not a tree but a list).

From within a node, we can do most of anything available to Python within the confines of a template. One of the more powerful features is the ability to add data to the template. In this section, we create a custom ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required