1
我需要通过名或姓搜索用户表过滤。使用django-filter过滤名或姓
给定用户John Doe Smith,其中John是First Name,Doe Smith是Last Name。
当我搜索约翰史密斯时,它应该找到上面的用户。
我知道它只是贯彻this SO answer解决的问题,但如何我这样做,在django-filter
,并保持其他筛选字段像email
或phone
也?
patient.py
(只有相关的部分)
class Patient(TimeStampedModel):
name = models.CharField('Name', max_length=30)
last_name = models.CharField('Last Name', max_length=30)
phone = models.CharField('Phone', max_length=14)
什么代码你尝试过吗?你的模型是什么? – wmorrell
啊,刚刚发现了FilterSet的'method'参数 –