I need to make a URL pattern which could work with this URL:
mysite.com/blog/12/بلاگ-مثال
It contains utf-8 characters so I tried using \X
:
re_path(r'^blog/?P<blog_id>[\d+]+/(?P<slug>[\X.*]+)/$', views.single_blog, name='single_blog')
But it didn't work. I don't know why. Maybe just because I'm not good in regex. So I tried a different pattern using just .*
to accept anything:
re_path(r'^blog/?P<blog_id>[\d+]+/(?P<slug>[.*]+)/$', views.single_blog, name='single_blog')
But this also doesn't work and I get:
The current path, blog/12/بلاگ-مثال, didn't match any of these.
So as I mentioned I'm not good in regex, what's the right way to fix this?
Is it the right time to say now I have two problems or regex is the only way?