views is like thiskwargs["Random Paragraph"] = Content.objects.order_by("?")[0].content
Is to randomly extract a paragraph each time
Then the index is like this
{{ 随机段落 }}
{{ 随机段落 }}
{{ 随机段落 }}
My purpose is to do this every time I call itRandom paragraph 1 Random paragraph 2 Random paragraph 3
To put it simply, every time the random paragraph tag is called, go to the database to extract the data
I don’t know if I understand your question.
According to my understanding, you need:
Write a random function
kwargs["随机段落"] = lambda: Content.objects.order_by("?")[0].content