djangodjango-templatescomponentsreusability

Components in Django


I have a latest news block on a page. It's a piece of markup in a template and some logic fetching the last n news in a view. How can I make a reusable component of it (like some CMS have) which I can include in a template like this:

{% component "latest_news" "5" %}

for building a block with 5 last news.

Seems Inclusion tags is quite good for this purpose, but I wonder may be is there some build-in component-like feature in Django?


Solution

  • The closest to CMS's components functionality in Django is Inclusion tags