Django NoReverseMatch Error When Using Slug [duplicate]
I'm a newbie working on a Django project, and encountering a NoReverseMatch error when trying to generate a URL using a slug in my template. theres a problem with html file, i think but couldn't solve
Error during template rendering
In template C:\\Users\\user\\Documents\\coding_files\\python\\website\\main\\templates\\menu.html, error at line 6
NoReverseMatch at /menu/
Reverse for 'post_detail' with keyword arguments '{'slug': ''}' not found. 1 pattern(s) tried: ['post/(? P<slug>[-a-zA-Z0-9_]+)\\\']
**views.py**
from django.shortcuts import render, get_object_or_404
from .models import Post
def post_detail(request, slug):
post = get_object_or_404(Post, slug=slug)
return render(request, 'menu.html', {'post': post})
**html file**
<a href="{% url 'post_detail' slug=post.slug %}">
<div class='dontknow'>
<img src="{% static 'img/image1.png' %}" class="logo">
</div>
</a>
**urls.py**
from django.urls import path
from . import views
urlpatterns = [
path('post/<slug:slug>/', views.post_detail, name='post_detail'),
]
the output should be if I click on the image in my HTML file, it should generate a URL with the slug and navigate to the post_detail view.