{"action":"created","comment":{"url":"https://api.github.com/repos/torchbox/wagtail/pulls/comments/30502558","id":30502558,"diff_hunk":"@@ -65,211 +65,111 @@ This should work the same way for Documents and custom models as well.\n .. _wagtailsearch_frontend_views:\n \n \n-Frontend views\n-==============\n-\n-\n-Default Page Search\n--------------------\n-\n-Wagtail provides a default frontend search interface which indexes the ``title`` field common to all ``Page``-derived models. Let's take a look at all the components of the search interface.\n-\n-The most basic search functionality just needs a search box which submits a request. Since this will be reused throughout the site, let's put it in ``mysite/includes/search_box.html`` and then use ``{% include ... %}`` to weave it into templates:\n-\n-.. code-block:: django\n-\n-  <form action=\"{% url 'wagtailsearch_search' %}\" method=\"get\">\n-    <input type=\"text\" name=\"q\"{% if query_string %} value=\"{{ query_string }}\"{% endif %}>\n-    <input type=\"submit\" value=\"Search\">\n-  </form>\n+An example page search view\n+===========================\n \n-The form is submitted to the URL of the ``wagtailsearch_search`` view, with the search terms variable ``q``. The view will use its own basic search results template.\n-\n-Let's use our own template for the results, though. First, in your project's ``settings.py``, define a path to your template:\n+You can add a \"Search\" page to your site using a Django view. Here's an example that you can use:\n \n .. code-block:: python\n \n-  WAGTAILSEARCH_RESULTS_TEMPLATE = 'mysite/search_results.html'\n-\n-Next, let's look at the template itself:\n-\n-.. code-block:: django\n-\n-  {% extends \"mysite/base.html\" %}\n-  {% load wagtailcore_tags %}\n-\n-  {% block title %}Search{% if search_results %} Results{% endif %}{% endblock %}\n-\n-  {% block search_box %}\n-    {% include \"mysite/includes/search_box.html\" with query_string=query_string only %}\n-  {% endblock %}\n-\n-  {% block content %}\n-    <h2>Search Results{% if request.GET.q %} for {{ request.GET.q }}{% endif %}</h2>\n-    <ul>\n-      {% for result in search_results %}\n-        <li>\n-          <h4><a href=\"{% pageurl result.specific %}\">{{ result.specific }}</a></h4>\n-          {% if result.specific.search_description %}\n-            {{ result.specific.search_description|safe }}\n-          {% endif %}\n-        </li>\n-      {% empty %}\n-        <li>No results found</li>\n-      {% endfor %}\n-    </ul>\n-  {% endblock %}\n+    # views.py\n \n-The search view provides a context with a few useful variables.\n+    from django.shortcuts import render\n+    from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger\n \n-  ``query_string``\n-    The terms (string) used to make the search.\n+    from wagtail.wagtailcore.models import Page\n+    from wagtail.wagtailsearch.models import Query\n \n-  ``search_results``\n-    A collection of Page objects matching the query. The ``specific`` property of ``Page`` will give the most-specific subclassed model object for the Wagtail page. For instance, if an ``Event`` model derived from the basic Wagtail ``Page`` were included in the search results, you could use ``specific`` to access the custom properties of the ``Event`` model (``result.specific.date_of_event``).\n \n-  ``is_ajax``\n-    Boolean. This returns Django's ``request.is_ajax()``.\n+    def search(request):\n+        # Search\n+        search_query = request.GET.get('query', None)\n+        if search_query:\n+            search_results = Page.objects.live().search(search_query)\n \n-  ``query``\n-    A Wagtail ``Query`` object matching the terms. The ``Query`` model provides several class methods for viewing the statistics of all queries, but exposes only one property for single objects, ``query.hits``, which tracks the number of time the search string has been used over the lifetime of the site. ``Query`` also joins to the Editor's Picks functionality though ``query.editors_picks``. See :ref:`editors-picks`.\n+            # Record hit","path":"docs/reference/search/searching.rst","position":85,"original_position":85,"commit_id":"240eb89265149e4802a9f021b1bd854b567124bd","original_commit_id":"240eb89265149e4802a9f021b1bd854b567124bd","user":{"login":"tomdyson","id":15543,"avatar_url":"https://avatars.githubusercontent.com/u/15543?v=3","gravatar_id":"","url":"https://api.github.com/users/tomdyson","html_url":"https://github.com/tomdyson","followers_url":"https://api.github.com/users/tomdyson/followers","following_url":"https://api.github.com/users/tomdyson/following{/other_user}","gists_url":"https://api.github.com/users/tomdyson/gists{/gist_id}","starred_url":"https://api.github.com/users/tomdyson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomdyson/subscriptions","organizations_url":"https://api.github.com/users/tomdyson/orgs","repos_url":"https://api.github.com/users/tomdyson/repos","events_url":"https://api.github.com/users/tomdyson/events{/privacy}","received_events_url":"https://api.github.com/users/tomdyson/received_events","type":"User","site_admin":false},"body":"does this need more explanation? e.g. \"Log the query so Wagtail can suggest promoted results\".","created_at":"2015-05-18T12:29:51Z","updated_at":"2015-05-18T12:29:51Z","html_url":"https://github.com/torchbox/wagtail/pull/1318#discussion_r30502558","pull_request_url":"https://api.github.com/repos/torchbox/wagtail/pulls/1318","_links":{"self":{"href":"https://api.github.com/repos/torchbox/wagtail/pulls/comments/30502558"},"html":{"href":"https://github.com/torchbox/wagtail/pull/1318#discussion_r30502558"},"pull_request":{"href":"https://api.github.com/repos/torchbox/wagtail/pulls/1318"}}},"pull_request":{"url":"https://api.github.com/repos/torchbox/wagtail/pulls/1318","id":35628144,"html_url":"https://github.com/torchbox/wagtail/pull/1318","diff_url":"https://github.com/torchbox/wagtail/pull/1318.diff","patch_url":"https://github.com/torchbox/wagtail/pull/1318.patch","issue_url":"https://api.github.com/repos/torchbox/wagtail/issues/1318","number":1318,"state":"open","locked":false,"title":"Update frontend search view docs","user":{"login":"kaedroho","id":1093808,"avatar_url":"https://avatars.githubusercontent.com/u/1093808?v=3","gravatar_id":"","url":"https://api.github.com/users/kaedroho","html_url":"https://github.com/kaedroho","followers_url":"https://api.github.com/users/kaedroho/followers","following_url":"https://api.github.com/users/kaedroho/following{/other_user}","gists_url":"https://api.github.com/users/kaedroho/gists{/gist_id}","starred_url":"https://api.github.com/users/kaedroho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaedroho/subscriptions","organizations_url":"https://api.github.com/users/kaedroho/orgs","repos_url":"https://api.github.com/users/kaedroho/repos","events_url":"https://api.github.com/users/kaedroho/events{/privacy}","received_events_url":"https://api.github.com/users/kaedroho/received_events","type":"User","site_admin":false},"body":"We no longer recommend using Wagtails built in search view.\r\n\r\nThis commit adds an example view that anyone can use in their project instead.","created_at":"2015-05-18T12:25:10Z","updated_at":"2015-05-18T12:29:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4642f9dc0ac4443ca709324586de8a28540e5135","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/torchbox/wagtail/pulls/1318/commits","review_comments_url":"https://api.github.com/repos/torchbox/wagtail/pulls/1318/comments","review_comment_url":"https://api.github.com/repos/torchbox/wagtail/pulls/comments{/number}","comments_url":"https://api.github.com/repos/torchbox/wagtail/issues/1318/comments","statuses_url":"https://api.github.com/repos/torchbox/wagtail/statuses/240eb89265149e4802a9f021b1bd854b567124bd","head":{"label":"kaedroho:frontend-search-docs","ref":"frontend-search-docs","sha":"240eb89265149e4802a9f021b1bd854b567124bd","user":{"login":"kaedroho","id":1093808,"avatar_url":"https://avatars.githubusercontent.com/u/1093808?v=3","gravatar_id":"","url":"https://api.github.com/users/kaedroho","html_url":"https://github.com/kaedroho","followers_url":"https://api.github.com/users/kaedroho/followers","following_url":"https://api.github.com/users/kaedroho/following{/other_user}","gists_url":"https://api.github.com/users/kaedroho/gists{/gist_id}","starred_url":"https://api.github.com/users/kaedroho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaedroho/subscriptions","organizations_url":"https://api.github.com/users/kaedroho/orgs","repos_url":"https://api.github.com/users/kaedroho/repos","events_url":"https://api.github.com/users/kaedroho/events{/privacy}","received_events_url":"https://api.github.com/users/kaedroho/received_events","type":"User","site_admin":false},"repo":{"id":16483819,"name":"wagtail","full_name":"kaedroho/wagtail","owner":{"login":"kaedroho","id":1093808,"avatar_url":"https://avatars.githubusercontent.com/u/1093808?v=3","gravatar_id":"","url":"https://api.github.com/users/kaedroho","html_url":"https://github.com/kaedroho","followers_url":"https://api.github.com/users/kaedroho/followers","following_url":"https://api.github.com/users/kaedroho/following{/other_user}","gists_url":"https://api.github.com/users/kaedroho/gists{/gist_id}","starred_url":"https://api.github.com/users/kaedroho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaedroho/subscriptions","organizations_url":"https://api.github.com/users/kaedroho/orgs","repos_url":"https://api.github.com/users/kaedroho/repos","events_url":"https://api.github.com/users/kaedroho/events{/privacy}","received_events_url":"https://api.github.com/users/kaedroho/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kaedroho/wagtail","description":"Django-based content management system","fork":true,"url":"https://api.github.com/repos/kaedroho/wagtail","forks_url":"https://api.github.com/repos/kaedroho/wagtail/forks","keys_url":"https://api.github.com/repos/kaedroho/wagtail/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kaedroho/wagtail/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kaedroho/wagtail/teams","hooks_url":"https://api.github.com/repos/kaedroho/wagtail/hooks","issue_events_url":"https://api.github.com/repos/kaedroho/wagtail/issues/events{/number}","events_url":"https://api.github.com/repos/kaedroho/wagtail/events","assignees_url":"https://api.github.com/repos/kaedroho/wagtail/assignees{/user}","branches_url":"https://api.github.com/repos/kaedroho/wagtail/branches{/branch}","tags_url":"https://api.github.com/repos/kaedroho/wagtail/tags","blobs_url":"https://api.github.com/repos/kaedroho/wagtail/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kaedroho/wagtail/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kaedroho/wagtail/git/refs{/sha}","trees_url":"https://api.github.com/repos/kaedroho/wagtail/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kaedroho/wagtail/statuses/{sha}","languages_url":"https://api.github.com/repos/kaedroho/wagtail/languages","stargazers_url":"https://api.github.com/repos/kaedroho/wagtail/stargazers","contributors_url":"https://api.github.com/repos/kaedroho/wagtail/contributors","subscribers_url":"https://api.github.com/repos/kaedroho/wagtail/subscribers","subscription_url":"https://api.github.com/repos/kaedroho/wagtail/subscription","commits_url":"https://api.github.com/repos/kaedroho/wagtail/commits{/sha}","git_commits_url":"https://api.github.com/repos/kaedroho/wagtail/git/commits{/sha}","comments_url":"https://api.github.com/repos/kaedroho/wagtail/comments{/number}","issue_comment_url":"https://api.github.com/repos/kaedroho/wagtail/issues/comments{/number}","contents_url":"https://api.github.com/repos/kaedroho/wagtail/contents/{+path}","compare_url":"https://api.github.com/repos/kaedroho/wagtail/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kaedroho/wagtail/merges","archive_url":"https://api.github.com/repos/kaedroho/wagtail/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kaedroho/wagtail/downloads","issues_url":"https://api.github.com/repos/kaedroho/wagtail/issues{/number}","pulls_url":"https://api.github.com/repos/kaedroho/wagtail/pulls{/number}","milestones_url":"https://api.github.com/repos/kaedroho/wagtail/milestones{/number}","notifications_url":"https://api.github.com/repos/kaedroho/wagtail/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kaedroho/wagtail/labels{/name}","releases_url":"https://api.github.com/repos/kaedroho/wagtail/releases{/id}","created_at":"2014-02-03T15:46:45Z","updated_at":"2015-05-07T09:34:19Z","pushed_at":"2015-05-18T12:24:19Z","git_url":"git://github.com/kaedroho/wagtail.git","ssh_url":"git@github.com:kaedroho/wagtail.git","clone_url":"https://github.com/kaedroho/wagtail.git","svn_url":"https://github.com/kaedroho/wagtail","homepage":null,"size":21157,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"torchbox:master","ref":"master","sha":"2940ea9c9beff94b47a46559937c8fb0512dd4d8","user":{"login":"torchbox","id":84015,"avatar_url":"https://avatars.githubusercontent.com/u/84015?v=3","gravatar_id":"","url":"https://api.github.com/users/torchbox","html_url":"https://github.com/torchbox","followers_url":"https://api.github.com/users/torchbox/followers","following_url":"https://api.github.com/users/torchbox/following{/other_user}","gists_url":"https://api.github.com/users/torchbox/gists{/gist_id}","starred_url":"https://api.github.com/users/torchbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/torchbox/subscriptions","organizations_url":"https://api.github.com/users/torchbox/orgs","repos_url":"https://api.github.com/users/torchbox/repos","events_url":"https://api.github.com/users/torchbox/events{/privacy}","received_events_url":"https://api.github.com/users/torchbox/received_events","type":"Organization","site_admin":false},"repo":{"id":16479108,"name":"wagtail","full_name":"torchbox/wagtail","owner":{"login":"torchbox","id":84015,"avatar_url":"https://avatars.githubusercontent.com/u/84015?v=3","gravatar_id":"","url":"https://api.github.com/users/torchbox","html_url":"https://github.com/torchbox","followers_url":"https://api.github.com/users/torchbox/followers","following_url":"https://api.github.com/users/torchbox/following{/other_user}","gists_url":"https://api.github.com/users/torchbox/gists{/gist_id}","starred_url":"https://api.github.com/users/torchbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/torchbox/subscriptions","organizations_url":"https://api.github.com/users/torchbox/orgs","repos_url":"https://api.github.com/users/torchbox/repos","events_url":"https://api.github.com/users/torchbox/events{/privacy}","received_events_url":"https://api.github.com/users/torchbox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/torchbox/wagtail","description":"A Django content management system focused on flexibility and user experience","fork":false,"url":"https://api.github.com/repos/torchbox/wagtail","forks_url":"https://api.github.com/repos/torchbox/wagtail/forks","keys_url":"https://api.github.com/repos/torchbox/wagtail/keys{/key_id}","collaborators_url":"https://api.github.com/repos/torchbox/wagtail/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/torchbox/wagtail/teams","hooks_url":"https://api.github.com/repos/torchbox/wagtail/hooks","issue_events_url":"https://api.github.com/repos/torchbox/wagtail/issues/events{/number}","events_url":"https://api.github.com/repos/torchbox/wagtail/events","assignees_url":"https://api.github.com/repos/torchbox/wagtail/assignees{/user}","branches_url":"https://api.github.com/repos/torchbox/wagtail/branches{/branch}","tags_url":"https://api.github.com/repos/torchbox/wagtail/tags","blobs_url":"https://api.github.com/repos/torchbox/wagtail/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/torchbox/wagtail/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/torchbox/wagtail/git/refs{/sha}","trees_url":"https://api.github.com/repos/torchbox/wagtail/git/trees{/sha}","statuses_url":"https://api.github.com/repos/torchbox/wagtail/statuses/{sha}","languages_url":"https://api.github.com/repos/torchbox/wagtail/languages","stargazers_url":"https://api.github.com/repos/torchbox/wagtail/stargazers","contributors_url":"https://api.github.com/repos/torchbox/wagtail/contributors","subscribers_url":"https://api.github.com/repos/torchbox/wagtail/subscribers","subscription_url":"https://api.github.com/repos/torchbox/wagtail/subscription","commits_url":"https://api.github.com/repos/torchbox/wagtail/commits{/sha}","git_commits_url":"https://api.github.com/repos/torchbox/wagtail/git/commits{/sha}","comments_url":"https://api.github.com/repos/torchbox/wagtail/comments{/number}","issue_comment_url":"https://api.github.com/repos/torchbox/wagtail/issues/comments{/number}","contents_url":"https://api.github.com/repos/torchbox/wagtail/contents/{+path}","compare_url":"https://api.github.com/repos/torchbox/wagtail/compare/{base}...{head}","merges_url":"https://api.github.com/repos/torchbox/wagtail/merges","archive_url":"https://api.github.com/repos/torchbox/wagtail/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/torchbox/wagtail/downloads","issues_url":"https://api.github.com/repos/torchbox/wagtail/issues{/number}","pulls_url":"https://api.github.com/repos/torchbox/wagtail/pulls{/number}","milestones_url":"https://api.github.com/repos/torchbox/wagtail/milestones{/number}","notifications_url":"https://api.github.com/repos/torchbox/wagtail/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/torchbox/wagtail/labels{/name}","releases_url":"https://api.github.com/repos/torchbox/wagtail/releases{/id}","created_at":"2014-02-03T12:41:59Z","updated_at":"2015-05-18T05:34:32Z","pushed_at":"2015-05-18T12:25:10Z","git_url":"git://github.com/torchbox/wagtail.git","ssh_url":"git@github.com:torchbox/wagtail.git","clone_url":"https://github.com/torchbox/wagtail.git","svn_url":"https://github.com/torchbox/wagtail","homepage":"wagtail.io","size":29377,"stargazers_count":2621,"watchers_count":2621,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":366,"mirror_url":null,"open_issues_count":269,"forks":366,"open_issues":269,"watchers":2621,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/torchbox/wagtail/pulls/1318"},"html":{"href":"https://github.com/torchbox/wagtail/pull/1318"},"issue":{"href":"https://api.github.com/repos/torchbox/wagtail/issues/1318"},"comments":{"href":"https://api.github.com/repos/torchbox/wagtail/issues/1318/comments"},"review_comments":{"href":"https://api.github.com/repos/torchbox/wagtail/pulls/1318/comments"},"review_comment":{"href":"https://api.github.com/repos/torchbox/wagtail/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/torchbox/wagtail/pulls/1318/commits"},"statuses":{"href":"https://api.github.com/repos/torchbox/wagtail/statuses/240eb89265149e4802a9f021b1bd854b567124bd"}}}}