Reputation: 31
I am getting an error in my django
project.
The /api
and /admin
urls are working fine, its only the main page that throws this error:
Using the
URLconf
defined inbackend.urls
,Django
tried these URL patterns, in this order:
api-auth/
admin/
api/
The empty path didn't match any of these.
You're seeing this error because you have
DEBUG = True
in yourDjango
settings file. Change that to False, andDjango
will display a standard 404 page.
My urls.py file is as follow
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('api-auth/', include('rest_framework.urls')),
path('admin/', admin.site.urls),
path('api/',include('movies.api.urls'))
]
Upvotes: 1
Views: 144
Reputation: 135
You have to specify the regex for the empty request ( Homepage)
from django.contrib import admin
from django.urls import path,re_path, include
urlpatterns = [
re_path(r'^', include('app_name.urls')),
path('api-auth/', include('rest_framework.urls')),
path('admin/', admin.site.urls),
path('api/',include('movies.api.urls'))
]
Upvotes: 2
Reputation: 16515
You have not defined a URL for your start page.
TemplateView
or something similar.you need to add a new URL to your patterns for that start page view; probably similar to this:
urlpatterns = [
path('', views.start_page, name='start_page'),
path('api-auth/', include('rest_framework.urls')),
path('admin/', admin.site.urls),
path('api/',include('movies.api.urls'))
]
Upvotes: 1