from django.db.models import Q

contact_item = Contact.objects.filter( Q(contact1_en=username) |Q(contact2_en=username))

  上述代码Q:模糊查询

                      | : or

    类似于下面的SQL语句(username为变量,应该为对应的字符串"****%")

select * from contact where contact1_en like username or contact2_en like username  

 

相关文章:

  • 2021-11-04
  • 2021-07-26
  • 2022-02-22
  • 2021-12-12
  • 2021-08-08
  • 2021-06-18
  • 2021-07-13
猜你喜欢
  • 2021-06-15
  • 2022-02-26
  • 2021-11-12
  • 2023-03-04
  • 2022-12-23
相关资源
相似解决方案