Hi, I’m bit stuck at the moment and don’t really know how to proceed. I have a template called chair-order-detailed-view.html in that template there are data that are fetched from database from model ChairOrder. There is also a button “Posalji narudžbu”, what I want to achieve is that when I click on that button the pk of that order is sent to the other view which renders template called “metal-sector.html”, that view should then fetch the order from database using pk, extract all the needed data for that sector from db and render it to “metal-sector.html”. I want when a worker from that sector goes to “metal-sector.html” to see order I have sent rendered in template. I am a beginner, so I don’t really know which is the best, most effective way to achieve this. Is it via signals, HTMX or some JS framework or something else?
None of the above. This is standard Django style processing.
You want to change how you think about this situation. Don’t focus on the templates, focus on the views and the URLs that are used to access those views from the browser. The templates are just the text being used by the view to create the page to be seen.
You mentioned that you are a beginner, so I’m going to assume that you have at least worked your way through the Official Django Tutorial. (If you haven’t, now’s the time to do it.)
You have a view that retrieves data, and then renders that data in a template to create a page.
When that view is rendering your template, it should include whatever information needs to be passed to the second view for that second view to render the data necessary.
This type of situation is precisely identical to the
polls application created in the tutorial, in that the tutorial creates a list of links - each linking to a different view but to render a different question depending upon the link selected.