Django Templates - DRY Templates, Partials, and Passing Context to Child Templates

preview_player
Показать описание
In this video, we'll learn some best practices for Django templates, including:

1. How to keep templates DRY by extracting common code to partials (or fragments)
2. How to include child HTML templates with the {% include %} template-tag.
3. How to pass dynamic/additional CONTEXT down to partial templates to customize them

📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
02:50 Extracting Common HTML to Partial Templates
04:22 Passing Context to Partial Templates
07:42 Passing 'Active' Context to Partial

☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:

▶️ Full Playlist:

𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:

#django #python
Рекомендации по теме
Комментарии
Автор

This was really helpful and to the point. Although I already knew some bits of this, there are some good tips I can take advantage of. Nice video. Greetings from Colombia

williamprada
Автор

Thanks a lot, I have been wondering if Django has this functionality for some time now

swelanauguste
Автор

Excellent. I use a similar technique for making bootstrap navbar elements active. I’ll have to give tailwind a go.

danfan
Автор

Really enjoying your content, very useful and straight to the point. I would love to see a video on custom model managers and querysets, as I've recently been using them to add dynamic queryset filtering based upon user permissions. It would be interesting to see how you approach problems where minimizing database hits for performance is important.

jamoinmoin
Автор

very helpful and relevant indeed! Thanks :)

rodsmade
Автор

Really interesting to see how you blend in the Don't Repeat Yourself principle in this scenario. 👀😀
Are you planning to do do more of that?
I'd love to see more about implementing other design principles like SOLID or design patterns, particularly in Django.
Thanks for this video BugBytes!

silkogelman