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

๐Ÿ‘ค2-sticks

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