(request)
return render_to_response(
        get_desktop_or_mobile_template(request, "blog", "post_list.html"),
        {
            "page_obj": returned_page,
            "object_list": returned_page.object_list,
            "search": query,
        },
    )
Search for a post by title or abstract. To search http://example.com/search?q=title

    Args:
        request (obj): Request object
Search for a post by title or abstract. To search http://example.com/search?q=title
Search for a post by title or abstract . To search http : // example . com / search?q = title
def get_search_results(request):
    """Search for a post by title or abstract. To search http://example.com/search?q=title

    Args:
        request (obj): Request object

    """
    # Get the query data
    query = request.GET.get("q", "")
    page = request.GET.get("page", 1)

    # Query the database
    results = Post.objects.filter(
        Q(title__icontains=query) | Q(abstract__icontains=query)
    )

    # Add pagination
    pages = Paginator(results, 5)

    # Get specified page
    try:
        returned_page = pages.page(page)
    except EmptyPage:
        returned_page = pages.page(pages.num_pages)

    # Display the search results
    return render_to_response(
        get_desktop_or_mobile_template(request, "blog", "post_list.html"),
        {
            "page_obj": returned_page,
            "object_list": returned_page.object_list,
            "search": query,
        },
    )
def get_search_results ( request ) : # Get the query data query = request . GET . get ( "q" , "" ) page = request . GET . get ( "page" , 1 ) # Query the database results = Post . objects . filter ( Q ( title__icontains = query ) | Q ( abstract__icontains = query ) ) # Add pagination pages = Paginator ( results , 5 ) # Get specified page try : returned_page = pages . page ( page ) except EmptyPage : returned_page = pages . page ( pages . num_pages ) # Display the search results return render_to_response ( get_desktop_or_mobile_template ( request , "blog" , "post_list.html" ) , { "page_obj" : returned_page , "object_list" : returned_page . object_list , "search" : query , } , )