How to use jinja2 tags in Django ajax

I have a function of doing evil, linkage query

clipboard.png

ajax

clipboard.png

ajax


content

jinja2



clipboard.png

how to write something like this.

in addition, is there any good method for such a linkage query

now most of the queries are selected, and then the server returns a list to ajax,ajax for splicing html rendering

feels that this kind of js stitching html is very difficult to write. All kinds of single quotation marks and double quotes ` "" make a mess, and the stitching of jinja2 content makes it even more troublesome

.
Nov.19,2021

The rendering logic of the

template-driven project is as follows: a template is written according to a template engine, which is used by the back end to render a html fragment, which is returned to the client, that is, the browser. Here you skip the compilation process of the template engine and insert the uncompiled template directly into the dom node.

the syntax of backfilling server templates on the client side is meaningless, because browsers do not recognize the jinja2 syntax, which is compiled by the backend template engine to get specific rendering results. Therefore, the correct solution should be to migrate the logic of if-else to the server, and the client is only responsible for stitching and rendering the server templates compiled by the backend, in other words, Migrate the logic to the server, leaving rendering and stitching on the client.

this kind of template-driven project is really troublesome to concatenate html strings. Generally, even if you use jquery , try not to manually stitch the html template and append directly under a dom node, but should use a more declarative way.

now that it is 2018 years old, it is also a good choice to use some lightweight mvvm frameworks, such as vue , which do not require any front-end engineering configuration, introduce and use them, and enjoy the convenience brought by responsiveness.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4937a-44d26.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4937a-44d26.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?