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
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/blog/posts/1/
Using the URLconf defined in monsite.urls, Django tried these URL patterns,
in this order:
1. admin/
2. [name='Home']
3. about/ [name='About']
4. contact/ [name='Contact']
5. blog/ [name='Blog']
6. 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?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/a526cfaf-c177-44f3-b6a3-68d241063aec%40googlegroups.com.