Enter any one of the last six digits of your mobile phone number or ID card, and one of the results will be returned.
Enter the mobile phone number and the last six digits of the ID card at the same time, and the result will be returned.
I would like to ask how to deal with this logic?
PHP中文网2017-05-27 17:41:19
mobile = request.GET.get('mobile', None)
id_no = request.GET.get('id_no', None)
data_list = XXX.objects.all()
if mobile:
data_list = data_list.filter(mobile=mobile)
if id_no:
data_list = data_list.filter(id_no=id_no)
迷茫2017-05-27 17:41:19
filter = {}
if mobile:
filter['mobile'] = mobile
if card:
filter['card'] = card
if status:
filter['status'] = status
TableModel.objects.filter(**filter)