Can't get request.POST with HTMX + Checked Attribute
I'm printing the POST result like this:
print(self.request.POST)
In the template, I'm trying to POST the name and value of the input field. It works when the checked attribute is not there but gives me an empty QueryDict <QueryDict: {}> when it's there as per below.
<div class="form-check form-switch">
<input
class="form-check-input"
type="checkbox"
role="switch"
id="survey-{{ survey.pk }}"
name="button"
value="{{ survey.published }}"
hx-post="{% url 'surveys:survey-toggle-status' %}"
hx-trigger="click"
hx-target="#survey-table"
/r/django
https://redd.it/1dn85zr
I'm printing the POST result like this:
print(self.request.POST)
In the template, I'm trying to POST the name and value of the input field. It works when the checked attribute is not there but gives me an empty QueryDict <QueryDict: {}> when it's there as per below.
<div class="form-check form-switch">
<input
class="form-check-input"
type="checkbox"
role="switch"
id="survey-{{ survey.pk }}"
name="button"
value="{{ survey.published }}"
hx-post="{% url 'surveys:survey-toggle-status' %}"
hx-trigger="click"
hx-target="#survey-table"
/r/django
https://redd.it/1dn85zr
Reddit
Can't get request.POST with HTMX + Checked Attribute : r/django
133K subscribers in the django community. News and links for Django developers.