I have a page that shows a list of objects and I want to add a button beside each one to enable the user to delete it. I've found a few questions about similar scenarios online but for some reason I keep getting errors when I try to replicate the solutions.
Here is the delete function in views.py:
def delete_dish(request, pk):
    query = Dish.objects.get_object_or_404(pk)
    supermenu = query['supermenu'].pk
    query.delete()
    return redirect('foodmenu:menu', supermenu)
Here is the form in the HTML template:
            {% if not supermenu.dish_set.count == 0 %}
            <ul>
            {% for dish in supermenu.dish_set.all %}
                <li>
                {{ dish.name }} - {{ dish.description }}
                <form action="{%  url 'foodmenu:delete_dish' dish.id %}" method="POST">
                    {% csrf_token %}
                    <button type="submit">X</button>
                </form>
                </li>
                    {% if not dish.price_set.count == 0 %}
                    <ul>
                    {% for price in dish.price_set.all %}
                        {% if price.label %}
                            <li>{{ price.label }}: {{ price.cost }}</li>
                        {% else %}
                            <li>{{ price.cost }}</li>
                        {% endif %}
                    {% endfor %}
                    </ul>
                    {% endif %}
                {% endfor %}
            </ul>
            {% else %}
            <p>No dishes on this menu!</p>
        {% endif %}
And here is the urls.py:
app_name = 'foodmenu'
urlpatterns = [
    ...
    path('dish/delete/<int:dish.id>', views.delete_dish, name="delete_dish")
]
When I click the button, the browser goes to ./dish/delete/1 (1 being the pk of the object), but Django returns a 404 error.
 
    