Calling Django JSON API from Template
Short answer, no. That's the basic flow of a Django App, you get requests and you respond.
The Django apps are running on a server machine. When you say App2 renders an html template, what it is doing is sending an HttpResponse with the given template, rendered, as payload to whoever requested it. This will be received in another machine, by another process.
So, if that other process (in another machine or the same) renders the text as an html, loads a website and shows a button, its not at all linked to your Django App. App2 ends its job when it renders and sends an HttpResponse. So if you want to control what ever happens when you press that button, you will need to communicate back with your server. And we do that sending http requests.
Say I have a django app called App1 and a django app called App2.
App1 has an endpoint called getJson() which returns a json object.
Now, in App2, I have an endpoint which renders an html template. In the html template I have a button and when the button is clicked, I want to call App1's getJson function. Is there a better way to do this than doing a get request in the JS of the template? If so, how?
Thanks!