HTMX method not activated on select from list action in template (view does not see HTMX)
Good afternoon
I have a micro Django app. In which I want to configure the ability to update the element using the [HTMX] method.
I have a small form in a template - which is based on selecting an item from a list. The list is displayed well and the items appear in it.
I connected this element in the template (selection list) with another element in the template - a graph.
I'm trying to activate the [HTMX] method in Django code, but nothing happens. The code action does not go further. It feels like the view is not finding and activating the [HTMX] action.
print("HTMX") - not action - print
What could be the reason? You may be able to find some error in the code. I would be very grateful for any information.
<hr/>
<div class="row">
<div class="col-4">
<form>
<select
id="select-name"
class="custom-select"
name="select"
autocomplete="off"
hx-get="{% url 'tabl_2_htmx' %}"
hx-target="#figure">
{% for select in selector %}
<option value="{{select}}">{{select}}</option>
{% endfor %}
</select>
</form>
</div>
<div id="figure" class="col-8">
{% include 'tabl_2_htmx_figure.html' %}
</div>
</div>
def tabl_2_htmx(request):
context = {}
queryset_selector = Model_1.objects.all()
last_row = queryset_selector.last()
values_selector = last_row.name_1
select_1 = request.GET.get('select', values_selector)
qs_select = Model_1.objects.filter(name_1=select_1).order_by('ud')
date = [d.date for d in qs_select]
cds = ColumnDataSource(data=data_x)
fig = figure(x_axis_type='datetime')
fig.line(x='date', y='ud', width=1, source=cds)
script_2, div_2 = components(fig)
context['script_2'] = script_2
context['div_2'] = div_2
menu_selector = Model.objects.all()
menu = [d.name for d in menu_selector]
print(menu)
context['selector'] = menu
if request.htmx:
print("HTMX")
return render(request, 'tabl_2_htmx_figure.html', context)
return render(request, "tabl_2_htmx.html", context)