Django Get Latest Entry from Database

前端 未结 5 1413
星月不相逢
星月不相逢 2020-12-11 02:46

I\'ve got 2 questions, but they are related to the same topic.

I know how to retrieve data from a for loop using template tags

{% for st         


        
5条回答
  •  再見小時候
    2020-12-11 03:31

    comments = usercomment.objects.order_by('-id')[:100]
    

    I Did By This Method

    First "comment" Is The Variable Name, "usercomment" Is Model Name, "id" is generated by django when make a model, [:100] is from 0 to 100 you can increase the number to infinite

提交回复
热议问题