MENU

Fun & Interesting

Django & HTMX - django-template-partials for Template Partial Responses

BugBytes 10,613 lượt xem 1 year ago
Video Not Working? Fix It Now

Blog Post: https://bugbytes.io/posts/rendering-template-fragments-with-django-template-partials/
Starter Code: https://github.com/bugbytes-io/template-partials-demo

In this video, we look at the new django-template-partials library, developed by Carlton Gibson. This library gives us an easy way to define and reference partial templates (template fragments) in our Django template code, and then return these partials as a response to an HTMX (or other) request.

📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Intro
03:13 Creating the Django template
05:39 Submitting form with HTMX
10:31 Returning template fragment with django-template-partials
17:00 Clearing form fields after HTMX request with form.reset() function

☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:
https://ko-fi.com/bugbytes

▶️ Full Playlist:
https://www.youtube.com/playlist?list=PL-2EBeDYMIbRByZ8GXhcnQSuv2dog4JxY

𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:
📖 Blog: https://bugbytes.io/posts/rendering-template-fragments-with-django-template-partials/
👾 Github: https://github.com/bugbytes-io/template-partials-demo
🐦 Twitter: https://twitter.com/bugbytesio

📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:
Starter Code: https://github.com/bugbytes-io/template-partials-demo
django-template-partials: https://github.com/carltongibson/django-template-partials
Carlton Gibson DjangoCon talk: https://www.youtube.com/watch?v=_3oGI4RC52s
Adding CSRF Token to POST request: https://django-htmx.readthedocs.io/en/latest/tips.html#make-htmx-pass-the-csrf-token

#python #django #webdevelopment #htmx

Comment