Reputation: 47
url_patterns=[
url(r'^(?P<postid>\d+)/preference/(?P<userpreference>\d+)/$', views.postpreference, name='postpreference'),
]
I got this code from Stack Overflow only but I know only path()
but don't know url()
I tried to understand and convert this url(r'^......)
to path(...)
using url() to path()
But I also want to know how to use "\d+"
in path()
.
Upvotes: 0
Views: 790
Reputation: 168967
\d+
is generally used for integers, so use the <int:>
converter:
path('<int:postid>/preference/<int:userpreference>/', views.postpreference, name='postpreference'),
Upvotes: 2