django 动态改变查询条件

def getModelResult(model,*orders,**wheres):

    ret=model.objects

    ret=ret.filter(**wheres)

    for order in orders:
        ret=ret.order_by(order)

    return ret

ret=getModleResult(Article,’-createtime’,uid=1,username=’aaa’)





总结:
wheres = {"name": "test", "age":18}
models.User.objects.filer(***wheres)
posted @ 2020-06-28 11:29  是张不是章啊  阅读(347)  评论(0编辑  收藏  举报