我有这个例子
from django.urls import include, path
from . import views
urlpatterns = [
path('sectionX/', include([
path('history/', views.historyX, name='historyX'),
])),
path('sectionY/', include([
path('history/', views.historyY, name='historyY'),
])),
]
如果我反向链接“ hystoryX”和“ historyY”,我得到相同的URL“ history /”,是否可以在反向中包括父urlpath?
要清楚,我想实现这样的目标
from django.urls import reverse
reverse("historyX") == "sectionX/historyX/"
reverse("historyY") == "sectionY/historyY/"
在每个URL中不重复URL前缀,可以吗?