📜 ⬆️ ⬇️

Blocks / modules or how to organize it?

For me, beautiful code is more than beautiful code. This is a code that is nice, and most importantly easy to maintain.

Any dynamic page of any site contains elements like “block” and “main content”.

In short, I suggest using “tags” for displaying blocks and view logic for displaying content. This will allow, for example, caching a block at the template level without writing a single line of python code.
')
Everything else we get the most broken into components of the system.

It should also be taken into account that in the main content it is also possible to find blocks and also put them into separate tags, followed only by the clarification that in the case of block attachment to data from the main content, this data must be thrown into the tag. You can use context, but this is not as obvious as passing parameters to the tag directly.

In any case, this is everyone’s business, deciding how to do it right :)

PS> It would be interesting to find out how you organize Django projects and what is the reason for this

Source: https://habr.com/ru/post/66463/


All Articles