Python wagtail.core.models.Page.search_fields() Examples
The following are 1
code examples of wagtail.core.models.Page.search_fields().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
wagtail.core.models.Page
, or try the search function
.
Example #1
Source File: test_page_search.py From wagtail with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_search_searchable_fields(self): # Find root page root_page = Page.objects.get(id=2) # Create a page root_page.add_child(instance=SimplePage( title="Hi there!", slug='hello-world', content="good morning", live=True, has_unpublished_changes=False, )) # Confirm the slug is not being searched response = self.get({'q': "hello"}) self.assertNotContains(response, "There is one matching page") search_fields = Page.search_fields # Add slug to the search_fields Page.search_fields = Page.search_fields + [SearchField('slug', partial_match=True)] # Confirm the slug is being searched response = self.get({'q': "hello"}) self.assertContains(response, "There is one matching page") # Reset the search fields Page.search_fields = search_fields