PyBookLearning / Django-No-Reverse-Match

Reverse for 'topic' not found. 'topic' is not a valid view function or pattern name
0 stars 0 forks source link

NoReverseMatch at /topic/ Reverse for ' topic' not found. ' topic' is not a valid view function or pattern name. #1

Open PyBookLearning opened 4 years ago

PyBookLearning commented 4 years ago

Hi everyone not even sure that is where I am supposed to write but I am new to python and programming in general. I am learning how to build a web app from a book and I am having trouble because I don't understand why my newly created URL 'topic' does not find a match. I have uploaded my three codes for this (urls, views and tempalte 'topic') as well as two additional files : topics.html which is a template with a link to 'topic' and the base template because my error seems to come from there according to Django but I can't figure out why.

cuinh commented 3 years ago

in your urls.py,

urlpatterns=[
    #Home Page
    path('', views.index, name='index'),
    # Topic Page
    path('topic/', views.topics, name='topics'),
    path('topics/<int:topic_id>/', views.topic, name='topic'),
]

path('topic/', views.topics, name='topics'),

should be:

path('topics/', views.topics, name='topics'),

I guess now you are quite clear about the difference after 8 months' learning. :=)