I have an element - dropdown list selector. Which works and there is a choice of value. Based on the value received, I send a request to execute the code and, at the end, to change / render another element (graph).
I added one more element to the template - one more selector list. And also redirected the change route to this element in the template. It also began to change based on the received value in the first selector list.
I’m thinking about how you can change the third element of the template (graph) - based on the values obtained - by the first and second elements (two selector lists). The first selector list - refines filters the model query.
The second selector list - refines, filters the model request more precisely - the values already left in the request after the first selector and already at the end sends the result to display in the form of a graph.
How can you think of changing only the schedule - rebuilding without changing the entire template? Whether it is possible to think up such by means of HTMX?
I would not try to do this in one view or template.
The first dropdown would call view 1 to replace the div containing the selection list for the second dropdown.
The second dropdown would call view 2 to build and render the graph and replace the div with that graph. You can include an hx-include attribute on that element to include the value of the first dropdown when issuing the get.
But I can’t figure out how I can move from this second list to the new view.
Can this be done using the redirect function or using the settings (HTMX)?
I recently started looking into updating and linking between elements on a page. And while this is very difficult to deal with.
I would be very grateful for any help.
if request.htmx:
print("HTMX")
if request.htmx:
print("HTMX")
print(select_kotol)
return render(request, 'zamer_tabl_2_htmx_select.html', context)
return render(request, "zamer_tabl_2_htmx.html", context)
But I can’t figure out how I can move from this second list to the new view.
Can this be done using the redirect function or using the settings (HTMX)?
I recently started looking into updating and linking between elements on a page. And while this is very difficult to deal with.
I would be very grateful for any help.
You want to change your thinking a little bit here. You’re not “connected” to a view in any sense of the word at all. Your browser submits requests to a url. It doesn’t matter what that url is or what url was previously used to retrieve content.
So don’t think of it as “moving” from one view to another. Think of it as “what view do I need to call to retrieve the proper content”.