Skip to content Skip to sidebar Skip to footer

NoReverseMatch At / List

I tried get dynamic link Error: NoReverseMatch at / Reverse for 'new_single' with keyword arguments '{'pk': 1}' not found. 1 pattern(s) tried: ['single/'] Code: view: {% for ne

Solution 1:

You are mixing two syntax variants to specify patterns. Since there are two ways to specify URL patterns: with path(..) [Django-doc], and with re_path(..) [Django-doc] for regular expressions-like patterns (an alias is url(..) [Django-doc]).

You however mix the two. You can use the two concurrently, but you need to specify per urlpatterns entry the correct one:

#  app/urls.py

from django.urls import path, re

urlpatterns = [
    url(r'^$', views.news_list, name='news_list'),
    path('single/<int:pk>/', views.new_single, name="new_single"),
]

Post a Comment for "NoReverseMatch At / List"