Hello friend the error is you've used a different name for regex.
Try to change "ids" in URLs to "id".
Example: path('posts/?P<id>[0-9]+', views.show),

Or easily with this : path("posts/<int:id>/", views.show)

Le mardi 26 mai 2020 00:50:35 UTC, Tiempo a écrit :
>
> 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/8e164853-53af-4dd0-988f-197217b4abd5%40googlegroups.com.

Reply via email to