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

3👍

I think you either just need to use blank ‘ ‘ as the path for index

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),
]

0👍

In Django 2.x.x, path() does not accept regular expressions. If you want to use regular expressions then you can use re_path() function like

from django.urls import path, re_path

urlpatterns = [
    re_path(r'^$',views.index,name='index'),
    path('admin/', admin.site.urls),
]

or simply use path() as suggested by @Antimada. The best practice is to use path() or at least avoid mixing both i.e. path() and re_path().

Leave a comment