django becomes the variable field to search

from ceshi.models import Student # model introduced in the model

The front end of the request acquisition parameters

searchKey=request.GET.get("key","id")

searchValue=request.GET.get("value","0")

searchList=Student.objects.filter(**{searchKey:searchValue})

Note: When the field searchKey must be a model class field, can not arbitrarily designated

Guess you like

Origin www.cnblogs.com/weilaibuxiangshuo/p/10978980.html