django中的sql语法

rm5edbpk  于 2021-07-26  发布在  Java
关注(0)|答案(1)|浏览(233)

我想在djnago中使用sql查询。如何将参数从函数的recieve参数发送到sql查询,例如我的代码是:

def products_filter(request, product, selling):
    all_product = Product.objects.raw("select * from product where product={{product}};")

如何在sql查询中使用产品和销售??

jv4diomz

jv4diomz1#

Product.objects.raw("select * from product where product= %s", [product])Product.objects.raw("select * from product where product= %s and selling= %s ", [product, selling]) 应该做什么
https://docs.djangoproject.com/en/3.0/topics/db/sql/

相关问题