Search code examples
python-3.xdjangodjango-viewsdjango-urlsdjango-apps

The empty path didn't match any of these URLs


Using the URLconf defined in first_project.urls, Django tried these URL patterns, in this order:

^$ [name='index']
admin/

The empty path didn't match any of these.

This is code in urls.py

from django.contrib import admin
from django.urls import path
from first_app import views
urlpatterns = [
    path('^$',views.index,name='index'),
    path('admin/', admin.site.urls),

Solution

  • path() should not have regex characters in it, you are confusing it with url()/re_path() syntax

    path('',views.index,name='index')