So I am able to create an HTML design document (CouchApp) that queries a view, runs some calculations, then puts everything into a nice JSON object and display the raw object in the browser/console, but I am wondering if there is a way to have the GET request for the HTML file return the JSON object directly?

I have to run multiple views on a large group of documents, and calling each one individually from Django takes too long. My goal here is to be able to httplib out to the HTML page, and just return the JSON object to my Django view.

有帮助吗?

解决方案

Sorry, there is not way to have it working the way you explained. Your CouchApp uses AJAX and does calculations using the javascript engine of the browser. Httplib will only get the html page for you, it won't evaluate the scripts.

What you probably need to is to have your data prepared in the list function instead of the couchapp. This is something you can easily invoke using httplib, its fed with the list of documents from the view and can return any http response.

Good luck!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top