[Answer]-No Product matches the given query – Search form

1👍

Change

return render('search.html', {'msg':message})

to

return render(request, 'search.html', {'msg':message})

and

<form class="search_form" action="search" method="get">
<input type="text" name="" Placeholder="Buscar">

to

<form class="search_form" action="/search/" method="get">
<input type="text" name="q" Placeholder="Buscar">
<input type="submit" value="Search" />

I found the source of “No Product matches the given query.” message. In urls.py

    url(r'^(?P<slug>[^/]+)/$', 'reviews.views.single_product'),

was executed before

    url(r'^search/$', 'reviews.views.search'),

Please change urls.py

From

    url('^accounts/logout/$', 'django.contrib.auth.views.logout'),
    #produt
    #url(r'^(?P<slug>.*)/$', 'single_product'),
    url(r'^(?P<slug>[^/]+)/$', 'reviews.views.single_product'),
    #submit reviews
    url('^(?P<slug>[^/]+)/review_submit/$','reviews.views.single_product'),
    #search
    url(r'^search/$', 'reviews.views.search'),    
)

to

    url('^accounts/logout/$', 'django.contrib.auth.views.logout'),
    #search
    url(r'^search/$', 'reviews.views.search'),
    #produt
    #url(r'^(?P<slug>.*)/$', 'single_product'),
    url(r'^(?P<slug>[^/]+)/$', 'reviews.views.single_product'),
    #submit reviews
    url('^(?P<slug>[^/]+)/review_submit/$','reviews.views.single_product'),
)

Leave a comment