admin管理员组文章数量:1300018
I have troubles to translate properly a route that needs a param. this works fine if the uri has /fr/ or /en/:
urlpatterns = [
path(_('CATEGORY'), views.category, name='app-category'),
]
But as long as I need to add a param like:
urlpatterns = [
path(f"{_('CATEGORY')}/<slug:uuid>", views.category, name='app-category'),
]
or
urlpatterns = [
path(_('CATEGORY') + "/<slug:uuid>", views.category, name='app-category'),
]
The translation stuck with 'category' so the route /fr/categorie/ is not working. _('CATEGORY') = 'categorie' for fr or 'category' for en.
Any idea about how to bypass the issue? Thanks
I have troubles to translate properly a route that needs a param. this works fine if the uri has /fr/ or /en/:
urlpatterns = [
path(_('CATEGORY'), views.category, name='app-category'),
]
But as long as I need to add a param like:
urlpatterns = [
path(f"{_('CATEGORY')}/<slug:uuid>", views.category, name='app-category'),
]
or
urlpatterns = [
path(_('CATEGORY') + "/<slug:uuid>", views.category, name='app-category'),
]
The translation stuck with 'category' so the route /fr/categorie/ is not working. _('CATEGORY') = 'categorie' for fr or 'category' for en.
Any idea about how to bypass the issue? Thanks
Share Improve this question asked Feb 11 at 14:46 Sacha Rk.Sacha Rk. 211 bronze badge1 Answer
Reset to default 0I finally find a way just in case it can help others.
#views.py
category_patterns = (
[
path("/<slug:slug>/", views.category_detail, name='category-detail'),
],
'category',
)
urlpatterns = [
path(_('[CATEGORY/]'), include(category_patterns, namespace="category")),
]
本文标签: Django 5 translate route with paramStack Overflow
版权声明:本文标题:Django 5 translate route with param - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741655901a2390758.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论