URL names must be unique otherwise reverse('url_name')
and {% url 'url_name' %}
will link to the "wrong" page half of the time.
Django uses the URL name to generate the view's URL. Like a dict
, only one entry can exist for a given "key".
If our GitHub code review bot spots this issue in your pull request it gives this advice:
1 | + | urlpatterns = [ | |
2 | + | path('', Home.as_view(), name="index"), | |
3 | + | path('index/', Index.as_view(), name="index"), |
URL names must be unique otherwise reverse('url_name')
and {% url 'url_name' %}
will link to the "wrong" page half of the time.
- | path('index/', Index.as_view(), name="index"), |
+ | path('index/', Index.as_view(), name="index-list"), |
4 | + | ] |