Given:
path("<int:artwork_id>/edit", views.catalog_edit, name="catalog_edit"),
Why does this url tag:
<button><a href="{% url 'catalog_edit' artwork.id 'edit' %}">Edit</a></button>
Fail with this error?
django.urls.exceptions.NoReverseMatch: Reverse for 'catalog_edit' with arguments '(717, 'edit')' not found. 3 pattern(s) tried: ['catalog/(?P<artwork_id>[0-9]+)/edit/catalog_detail\\Z', 'catalog/(?P<artwork_id>[0-9]+)/edit\\Z', 'catalog/(?P<artwork_id>[0-9]+)\\Z']
Your url only takes one parameter. There’s no need for the string ‘edit’ in that tag.
Comment redacted for now…
There’s something else that I think I just noticed as a possible issue - do you have more than one path
definition using the name catalog_edit
? If so, that’s a mistake. Each path
definition should have a unique name. (This is in addition to ensuring that you’re passing the right number of parameters to the url
tag.)
Hi Ken. That wasn’t the issue (another path was grabbing the url, didn’t notice it), but thanks for the suggestion… I didn’t know that each path needs its own description. Makes sense.