Re: Combine page content (html) and model instance (json) in ajax response

2014-06-13 Thread Max Demars
I got the solution from Daniel Rossman on SO: Firstly, use `render_to_string` to get the template fragment as an HTML string. Secondy, serialize your object as a Python dict, not JSON. Then you can convert the whole lot to JSON in one go. html = render_to_string("page_content.html", {'form'

Combine page content (html) and model instance (json) in ajax response

2014-06-12 Thread Max Demars
I would like my view to return the page content and some parameters that I would like to use in the Ext.Ajax.request success function. views.py def importFile(request): form = ImportVectorForm() html_response = render_to_response("page_content.html", {'form': form, 'folder':