adamchainz / django-htmx

Extensions for using Django with htmx.
https://django-htmx.readthedocs.io/
MIT License
1.64k stars 140 forks source link

Add a shortcut for hx-vals #308

Closed louisgavalda closed 12 months ago

louisgavalda commented 1 year ago

Description

Hi Adam,

Thank you for maintaining this library, it is very practical to have almost all HTMX shortcuts so nicely integrated in Django.

I miss one though: did you ever considered adding a shortcut for hx-vals ? It could be pretty useful.

The hx-vals attribute allows you to add to the parameters that will be submitted with an AJAX request.

I am accessing those values when doing stuff like that: https://github.com/spookylukey/django-htmx-patterns/blob/master/inline_partials.rst#block-selection-in-the-template

Thank you very much.

Regards.

;-)

adamchainz commented 1 year ago

What do you imagine this filter would do? Basically json.dumps() ?

kdmwangi commented 1 year ago

Hello Adam, I've been going through the library trying to figure out how {% if DEBUG %} actually works the template itself doesnt pass the variable and I have checked the javascript files. I would just like to grasp the concept. Thanks

kdmwangi commented 1 year ago

Hello Adam, I've been going through the library trying to figure out how {% if DEBUG %} actually works the template itself doesnt pass the variable and I have checked the javascript files. I would just like to grasp the concept. Thanks

oh i actually missed the part where you actually have configured a django template that returns the variable debug as a boolean. my bad

adamchainz commented 1 year ago

@kdmwangi thanks for saying you found an answer. Your question was off topic for this issue so I’m hiding your comments.

adamchainz commented 12 months ago

Closing due to inactivity. I don't think we need any particular helpers for hx-vals.