library_views.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:Plamber 作者: OlegKlimenko 项目源码 文件源码
def find_books(request):
    """
    Generates list with books of data which user entered. At first it check full equality in name,
    after tries to check if contains some part of entered data.
    """
    if request.is_ajax():
        search_book_form = SearchBookForm(request.GET)

        if search_book_form.is_valid():
            search_data = search_book_form.cleaned_data['data']

            filtered_books = Book.exclude_private_books(request.user, Book.fetch_books(search_data))
            books = Book.generate_books(filtered_books)

            for book in books:
                book['name'] = escape(book['name'])
                book['author'] = escape(book['author'])

            return HttpResponse(json.dumps(books), content_type='application/json')
    else:
        return HttpResponse(status=404)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号