1,根据排序结果删除部分
not_delete_list= M_log.objects.filter(user='xxx').order_by('-id')[:4].values_list("id",flat=True)
M_log.objects.exclude(pk__in=list(not_delete_list) ).delete()
1,根据排序结果删除部分
not_delete_list= M_log.objects.filter(user='xxx').order_by('-id')[:4].values_list("id",flat=True)
M_log.objects.exclude(pk__in=list(not_delete_list) ).delete()
本文标题:django models 模型操作
本文链接:https://www.haomeiwen.com/subject/oampiftx.html
网友评论