[Django]-HTMX + Django – Edit a ModelForm in a HTML Table

5πŸ‘

βœ…

For partial rendering of edit row you should not extend the whole base.html. That is causing problems #1 and #2. Here partial rendering with django and htmx is nicely explained.

For #3 submitting the data you are missing hx-include="closest tr" on your submit button. See the demo page you linked and check hx params on submit button. That way your inputs are picked up from the row, without it and without form it just issues empty put.

πŸ‘€preator

1πŸ‘

As praetor mentioned, it was due to the lack of the β€˜closest tr’ option on the hx-include tag.

Forms do not work well within tags, and htmx does not send the form data automatically in such cases, so it has to be explicitly mentioned.

I also recommend checking out django-render-blocks library, it makes render partials with htmx much simpler than using template fragments.

πŸ‘€V S

Leave a comment