Почему не находит страницу? Django
Я делаю поисковую систему,так чтобы она находила определённый товар на сайте. Путь полностью совпадает с тем, который я прописал в сatalog.urls, но страницу все равно не находит.
catalog/urls.py
from django.urls import path, re_path
from apps.catalog import views
app_name = 'catalog'
urlpatterns = [
path('', views.CatalogListView.as_view(), name='main'),
path('<name>', views.ProductView.as_view(), name='toy'),
path('ajax-comment/<name>', views.AjaxComment.as_view(), name='comment'),
path('category/<category>', views.SelectedCategoriesView.as_view(), name='category'),
path('search/?query=<search>', views.SearchView.as_view(), name='search')
]
urls.py
from django.contrib import admin
from django.urls import path, include
from django.conf.urls.static import static
from django.conf import settings
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('apps.company.urls')),
path('user/', include('apps.users.urls')),
path('__debug__/', include('debug_toolbar.urls')),
path('order/', include('apps.order.urls')),
path('catalog/', include('apps.catalog.urls'),),
path('pages', include('django.contrib.flatpages.urls')),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
views.py
class SearchView(ListView):
template_name = 'catalog/catalog.html'
context_object_name = 'products'
paginate_by = 5
def get_queryset(self):
return Product.objects.filter(
Q(name__icontains=self.kwargs['search']) |
Q(description__icontains=self.kwargs['search']) |
Q(year__icontains=self.kwargs['search']) |
Q(brand__icontains=self.kwargs['search'])
)
def get_context_data(self, **kwargs):
categories = Category.objects.all()
context = super(SearchView, self).get_context_data(**kwargs)
context['categories'] = categories
return context
catalog.html
<form class="search" action="search/" method="GET">
<input type="text" class="search__input" placeholder="Search" name="query">
<button class="search__btn">Search</button>
</form>
debuger