0

我有两条单独的路线

 re_path(
    r"something/(?P<slug>name_one|name_two)/$",
    views.SomeView.as_view(template_name='some_template.html'),
    name='something'
),
re_path(
    r"something/(?P<slug>name_one|name_two)/(?P<params>p_one|p_two)/$",
    views.SomeView.as_view(template_name='some_template.html'),
    name='something_extera'
),

我希望这些路线接受特定的字符串,只要您在上面的路线中看到。例如

something/name_one
something/name_two
something/name_one/p_one
something/name_one/p_two
...

但我得到错误

django.urls.exceptions.NoReverseMatch: Reverse for 'something' with arguments '('',)' not found. 1 pattern(s) tried: ['something/(?P<slug>name_one|name_two)$']
4

0 回答 0