Answer the question
In order to leave comments, you need to log in
Are macros necessary in Django templates?
Hello.
There is a question. How to make DRY without macros in templates, while remaining within the framework of the template engine, and not leaving view.py?
As you know, there are no macros in django-templates. And I want to place a complex search form in two places on the page. How to be?
There is a funny opinion in the community that "if something is not implemented, then this is a bad approach." Macros are clearly not implemented (although there has been a snippet for four years ). Is this a bad approach? Are you using this approach? If you don't use it, please tell me how to do it.
Let me explain where this question comes from. A long time ago I decided to use Jinja2 as my Django templating engine. After two years of such work, I realized that the main plus that he (she?) Provides - rendering speed - is covered by many shortcomings: lack of support from the IDE, inconvenience of template debugging, slow development, inconvenience of creating tags and filters, etc. I returned to django-templates, but there are no macros and poor if.
Thank you.
Answer the question
In order to leave comments, you need to log in
The inclusion tag
seems to fit the best .
PS Nothing wrong with snippets IMHO
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question