So i have a simple model and i want to display list of my recipes. So in urls.py i have following url:
urlpatterns = [
url(
regex=r'^$',
view=views.RecipeListView.as_view(),
name='list'
),
url(
regex=r'^(?P<name>[\w.@+-]+)/$',
view=views.RecipeDetailView.as_view(),
name='detail'
),
]
name is just a name of recipe it can be anything. And than at my list i have following to give url:
<div class="list-group">
{% for recipe in recipe_list %}
<a href="{% url 'recipes:detail' recipe.name %}" class="list-group-item">
<h4 class="list-group-item-heading">{{ recipe.name }}</h4>
</a>
{% endfor %}
</div>
so i am passing argument of name into detail view but i still get error NoReverseMatch at /recipes/
Reverse for 'detail' with arguments '(u'This is my test recipe',)' and keyword arguments '{}' not found. 1 pattern(s) tried: [u'recipes/(?P[0-9A-Za-z._%+-]+)/$']
And i am not sure what i am doing wrong.