Search code examples
pythondjangodjango-viewsdjango-urls

The empty path didn’t match any of these


I am very new in Django & trying to run my first project. But stucked in the error "The empty path didn’t match any of these." as mentioned above. In my app urls I have the following code

from django.urls import path
from . import views

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

And in my project urls I have the following code.

from django.contrib import admin
from django.urls import include, path

urlpatterns = [
path('', include('members.urls')),
path('admin/', admin.site.urls),
]

I read a number of answers of this question & found suggestion that not working for me.Seeking help to dig into the error.

Here is the full error tracbac:

Page not found (404)
Request Method: GET
Request URL:    http://127.0.0.1:8000/
Using the URLconf defined in my_tennis_club.urls, Django tried 
these URL patterns, in this order:

members/ [name='members']
admin/
The empty path didn’t match any of these.

You’re seeing this error because you have DEBUG = True in your 
Django settings file. Change that to False, and Django will display 
a standard 404 page.

Solution

  • update this:

    from django.urls import path
    from . import views
    
    urlpatterns=[
    path('members/',views.members,name='members'),
    ]
    

    to the following:

    from django.urls import path
    from . import views
    
    urlpatterns=[
    path('',views.members,name='members'),
    ]