I am new to django
In urls.py, I set path like this. I tried to create a page with urls: localhost:8000/topics/1/
urlpatterns = [
path('topics/(?P<topic_id>\d+)/', views.topic, name='topic'),
]
In views.py. Code is this:
def topic(request, topic_id):
"""Show a single topic and all its entries"""
topic = Topic.objects.get(id=topic_id)
entries = topic.entry_set.order_by('date_added')
context = {'topic': topic, "entries": entries}
return render(request, 'learning_logs/topic.html', context)
I got error 404 when enter localhost:8000/topics/1/.
topics/(?P\d+)/ [name='topic']
The current path, topics/1/, didn't match any of these.
But the correct urls turns out to be: localhost:8000/topics/(%3FP1%5Cd+)/
Is there something wrong with the path in urls or what's the problem?