URL name not unique

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".

So in practice, do this


    # in urls.py
    urlpatterns = [
        path('', Home.as_view(), name="home"),
        path('my-fox-holes/', MyFoxHoles.as_view(), name="my-fox-hole"),
    ]

Instead of this


    # in urls.py
    urlpatterns = [
        path('', Home.as_view(), name="home"),
        path('my-fox-holes/', MyFoxHoles.as_view(), name="home"),
    ]


Are you affected by this? Audit your codebase in seconds to find out.

Configuring this check

Django Doctor will run this check by default. No configuration is needed but the check can be turned on/off using check code non-unique-url-name in your pyproject.toml file.

Read more about configuring Django Doctor.