我想在djnago中使用sql查询。如何将参数从函数的recieve参数发送到sql查询,例如我的代码是:
def products_filter(request, product, selling): all_product = Product.objects.raw("select * from product where product={{product}};")
如何在sql查询中使用产品和销售??
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/
Product.objects.raw("select * from product where product= %s", [product])
Product.objects.raw("select * from product where product= %s and selling= %s ", [product, selling])
1条答案
按热度按时间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/