Hi,
my name is Tiempo and I'm new with Django. currently, I'm using django 3.0 and i want to display each article of a blog app ( like when I click on article 1, it should display it full details on page show with the following link
http://127.0.0.1:8000/blog/posts/1/)
containing a parameter named id (of an article) but the path is not recognized :
urlpatterns = [
path('', views.index, name='Blog'),
path('posts/?P<ids>[0-9]+', views.show),
This is how I called the function show in views:
def show(request, id):
return render(request, 'blog/show.html', {'id': id})
This is what happens when I execute the local server
Using the URLconf defined in monsite.urls, Django tried these URL patterns, in this order:
- admin/
- [name='Home']
- about/ [name='About']
- contact/ [name='Contact']
- blog/ [name='Blog']
- blog/ posts/?P<ids>[0-9]+
The current path, blog/posts/1/, didn't match any of these.
can someone help me with how to write the regular expression in Django 3.0, please?