django-crispy-forms and HTMX integration #3 - Field validation and the hx-swap-oob attribute

Опубликовано: 30 Январь 2022
на канале: BugBytes
8,373
195

This video extends the form built in the previous video, and includes HTMX-driven field validation. We'll see how to use HTMX attributes on Django Form fields, and how to use the hx-swap-oob attribute to disable the form's submit button when we have validation errors.

We'll also see how to make use of a handy function "as_crispy_field()" form django-crispy-forms. This generates the HTML for a particular field on our form, which we can then swap into the DOM after validation, using HTMX.

▶️ Full Playlist:
   • Django-crispy-forms & HTMX  

📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Intro
00:27 Validating username field
01:00 Adding HTMX attributes to username
01:44 Username validation URL and view
03:51 Generating field with as_crispy_field function
07:07 Trigger filters and modifiers
08:31 Adding subject field validation
11:47 Subject validation URL and view
13:18 Disable button with hx-swap-oob

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

𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:
📖 Blog: https://www.bugbytes.io/posts/
👾 Github: https://github.com/bugbytes-io/crispy...
🐦 Twitter:   / bugbytesio  

📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:
Django form validation: https://docs.djangoproject.com/en/4.0...
django-crispy-forms: https://django-crispy-forms.readthedo...
hx-swap-oob: https://htmx.org/attributes/hx-swap-oob/
HTMX docs: https://htmx.org/docs/

#django #python #htmx


Смотрите видео django-crispy-forms and HTMX integration #3 - Field validation and the hx-swap-oob attribute онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь BugBytes 30 Январь 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 8,37 раз и оно понравилось 19 людям.