On Mon, 3 Dec 2018 at 11:51, <ehrenfeld1946@gmail.com> wrote:
On Sunday, December 2, 2018 at 10:00:17 AM UTC-8, Jani Tiainen wrote:Hi.Path is a new url format which uses format of <parser:variable> for exanple like <int:path> . If you want to use regular expressions use re_path instead.<ehrenf...@gmail.com> kirjoitti su 2. jouluk. 2018 klo 19.42:When I run http://localhost:8000/posts/2Here is my .py's
from django.contrib import admin
from django.urls import path
from posts import views
from django.conf.urls.static import static
from django.conf import settings
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.home),
path('posts/(?P<post_id>[0-9]+)/$', views.post_details),
] + static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)
So, to your urls.py you need to add:
from django.urls import path, re_path
And your url patterns will need to look like
re_path('posts/(?P<post_id>[0-9]+)/$', views.post_details),
I've not looked for a while, but it might even need to be
re_path(r'posts/(?P<post_id>[0-9]+)/$', views.post_details),
Cheers
L.
------
"The fact that you're still saying something like 'feminism gone mad' suggests that feminism hasn't gone mad ENOUGH yet."
Helen Zaltzman / @HelenZaltzman
https://twitter.com/HelenZaltzman/status/1065384934846545920
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGBeqiPuTq_4N2dd9nBDDPfFfOo0Ra_0Q23i5k0Wjgmhe4%2B5KQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment