Django Template - Convert a Python list into a JavaScript object

后端 未结 4 1477
谎友^
谎友^ 2020-12-30 02:19

I am working on a Django / Python website. I have a page where I want to display a table of search results. The list of results is passed in to the template as normal.

4条回答
  •  生来不讨喜
    2020-12-30 02:59

    Look this answer too.

    But it isn't highload way. You must:

    a) Create JSON files, place to disk or S3. In case is JSON static

    b) If JSON is dynamic. Generate JSON on separately url (like API) in your app.

    And, load by JS directly in any case. For example:

    $.ajax('/get_json_file.json')

    P.S.: Sorry for my English.

提交回复
热议问题