On Tuesday, 26 May 2020 01:50:35 UTC+1, Tiempo wrote:
>
> 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?
>
>

What gave you the impression you should be using regular expressions? 
`path` does not take regex and you should not be using them in Django 3.0. 

The correct syntax is:

    path('posts/<int:id>/', views.show),

--
DR.

-- 
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/7773531e-c559-4b3c-9c02-bec32089f5fe%40googlegroups.com.

Reply via email to