Вот views.py
#search
def search(request):
query = request.GET.get["query"]
if len(query)>78:
allItem = Item.object.none()
else:
allItemTitle = Item.object.filter(title__icontains=query)
allItemDescription = Item.object.filter(description__icontains=query)
allItem = allItem.Title.union(allItemDescription)
if allItem.count() == 0:
messages.warning(request, "No result found")
params = {'allItem': allItem, 'query':query}
return render(request, 'home/search.html', params)
#search
Вот url.py
path('search/', views.Search, name='search'),
и, наконец, HTML Исходный код здесь
{% extends 'base.html' %}
{% load static %}
{% block content %}
<div class="breadcrumb-area section-padding-1 bg-gray breadcrumb-ptb-2">
<div class="container-fluid">
<div class="breadcrumb-content text-center">
<div class="breadcrumb-title">
<h2>Shop 3 Column</h2>
</div>
<ul>
<li>
<a href="index.html">Home 01 </a>
</li>
<li><span> > </span></li>
<li class="active"> shop </li>
</ul>
</div>
</div>
</div>
<div class="shop-area pt-70 pb-100">
<div class="container">
<div class="container">
<h3>Search Results</h3>
{% if allItem|length < 1 %}
<p>No Search result found</p>
did not match any document Your search query:<b>{{query}}</b>
{% endif %}
<div class="row">
{% for item in object_list %}
<div class="col-lg-4 col-md-6 col-sm-6 col-12">
<div class="product-wrap mb-50">
<div class="product-img default-overlay mb-25">
<a href="{{ item.get_absolute_url }}">
<img class="default-img" src="{{ item.image }}" height="463" width="370"alt="">
<span class="badge-black badge-right-0 badge-top-0 badge-width-height-1">{{ item.label }}</span>
</a>
<div class="product-action product-action-position-1">
<a title="Add to Cart" href="{{ item.link }}" target="_blank"><i class="fa fa-shopping-cart"></i><span>Shop Now</span></a>
</div>
</div>
<div class="product-content-2 title-font-width-400 text-center">
<h3><a href=""></a>{{ item.title }}</a></h3>
<div class="product-price">
{% if item.old_price %}
<span class="new-price"><b>$ {{ item.price }}</b></span>
<span class="old-price" style="color: red;">$ {{ item.old_price }} </span>
{% else %}
<span class="new-price"><b>$ {{ item.price }}</b></span>
{% endif %}
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
{% include 'footer.html' %}
{% endblock %}
<!---search-->
<div class="search-content-2 search-content-2-mrg">
<form class="search-form" action="{% url 'roserga:search' %}">
<input type="text" name="query" placeholder="Search">
<button class="button-search" type="submit"><i class="dlicon ui-1_zoom"></i></button>
</form>
</div>
</div>
<!---search end-->
много раз пытались разрешить, но не повезло, запрос не принял тег тела и не показал результатов.