i'm try to make some website using django and i got some error message like this
Request URL: http://127.0.0.1:8000/store.html
Using the URLconf defined in greatkart.urls, Django tried these URL patterns, in this order:
admin/
[name='home']
store/
^media/(?P<path>.*)$
The current path, store.html, didn't match any of these.
the problem is when i tried to click button it's allways print ./store.html not the ./store it's my html code for the button
<a href="./store.html" class="btn btn-outline-primary float-right">See all</a>
and this is my django for urls.py (main)
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.home, name='home'),
path('store/', include("store.urls"))
] static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)
this urls.py(store)
urlpatterns = [
path('', views.store, name='store'),
path('<slug:category_slug>/', views.store, name='product_by_category'),
]
views.py
def store(request, category_slug = None):
return render(request, 'store/store.html', context)
anyone have some idea? i want to fix it without change html code because I've tried it and when i click on the buttons twice that make some error because the url print the ./store twice
CodePudding user response:
Here the url should be absolute(starting with a /
excluding you localhost address) and should not include .html
.
So Your Url should be :
/store
and the anchor tag should be :
<a href="/store" class="btn btn-outline-primary float-right">See all</a>