[Answer]-Render JSON objects through Django template-tag

1👍

Templatetags are server-side, so no, you cannot use django’s templating to handle the result of an Ajax request – not directly at least. Possible solutions :

  • you can eventually write a view that would take your json data and returns formatted html, but that’s going to be a bit on the heavy side.

  • if the json comes from your own application, you could return an html fragment instead of json.

  • if the json comes from another site, you could also have a view in your app doing the request and returning a formatted html fragment from the json (then you’d post to this view).

  • finally if you’re app is heavy on ajax/json stuff, you may want to use some js templating framework or something like angular.js

Leave a comment