本文整理汇总了Python中temba.contacts.models.Contact.search方法的典型用法代码示例。如果您正苦于以下问题:Python Contact.search方法的具体用法?Python Contact.search怎么用?Python Contact.search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类temba.contacts.models.Contact
的用法示例。
在下文中一共展示了Contact.search方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_contact_search
# 需要导入模块: from temba.contacts.models import Contact [as 别名]
# 或者: from temba.contacts.models.Contact import search [as 别名]
def test_contact_search(self):
contacts = self._create_contacts(10000, ["Bobby", "Jimmy", "Mary"])
self._create_values(contacts, self.field_nick, lambda c: c.name.lower().replace(' ', '_'))
with SegmentProfiler("Contact search with simple query", self, force_profile=True):
qs, is_complex = Contact.search(self.org, 'bob')
self.assertEqual(3334, qs.count())
self.assertEqual(False, is_complex)
with SegmentProfiler("Contact search with complex query", self, force_profile=True):
qs, is_complex = Contact.search(self.org, 'name = bob or tel has 078 or twitter = tweep_123 or nick is bob')
self.assertEqual(3377, qs.count())
self.assertEqual(True, is_complex)
示例2: get_queryset
# 需要导入模块: from temba.contacts.models import Contact [as 别名]
# 或者: from temba.contacts.models.Contact import search [as 别名]
def get_queryset(self, **kwargs):
qs = super(ContactListView, self).get_queryset(**kwargs)
org = self.request.user.get_org()
# contact list views don't use regular field searching but use more complex contact searching
query = self.request.REQUEST.get('search', None)
if query:
qs, self.request.compiled_query = Contact.search(org, query, qs)
return qs.prefetch_related('groups')
示例3: get_queryset
# 需要导入模块: from temba.contacts.models import Contact [as 别名]
# 或者: from temba.contacts.models.Contact import search [as 别名]
def get_queryset(self, **kwargs):
qs = super(ContactListView, self).get_queryset(**kwargs)
qs = qs.filter(is_test=False)
org = self.request.user.get_org()
# contact list views don't use regular field searching but use more complex contact searching
query = self.request.REQUEST.get('search', None)
if query:
qs, self.request.compiled_query = Contact.search(org, query, qs)
return qs.extra(select={'lower_contact_name': 'lower(contacts_contact.name)'}).order_by('lower_contact_name', 'pk').prefetch_related('all_groups')