shaare.it

TypeError: url `urlpatterns` must be a list

7 Dec 2025

1 min read

TypeError: url urlpatterns must be a list

$ python manage.py runserver
...
TypeError: urlpatterns must be a list or tuple

Why this happens

You set urlpatterns to a dict or other type.

Fix

Use a list or tuple.

Wrong code

urlpatterns = { 'index': path('', views.index) }

Fixed code

urlpatterns = [ path('', views.index) ]