Skip to content

Commit

Permalink
Use autocomplete in AJAX search form
Browse files Browse the repository at this point in the history
  • Loading branch information
Tijani-Dia authored and thibaudcolas committed Nov 3, 2023
1 parent 890b057 commit 2ce7b60
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions apps/search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,11 @@ def get_parent_section(self, page):

@api_view(["GET"])
def search_json(request):

search_query = request.GET.get("query", None)

# Search
if search_query:
if search_query := request.GET.get("query"):
search_results = (
Page.objects.live().filter(locale=Locale.get_active()).search(search_query)
Page.objects.live()
.filter(locale=Locale.get_active())
.autocomplete(search_query)
)
query = Query.get(search_query)

Expand Down

0 comments on commit 2ce7b60

Please sign in to comment.