[Fixed]-Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:

6👍

Your url conf regex is incorrect, you have to use $ instead of %.

from django.conf.urls import url

from . import views

urlpatterns = [
   url(r'^$', views.index, name='index'),
]

The $ acts as a regex flag to define the end of the regular expression.

👤v1k45

2👍

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

1👍

I ran into the same issue with the tutorial!

The issue is that if you look closely it references two url.py files, mysite/polls/url.py and mysite/url.py.

Putting the provided code in the correct url.py files should correct the issue.

0👍

Adding STATIC_URL and STATIC_MEDIA when debug is ON, helped me:

from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static


urlpatterns = [
    url(r'^$', views.index, name='index'),
]

if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
👤Vova

Leave a comment