0xgareth
0xgareth

Reputation: 621

'Not Found: /' error when linking app urls.py to project's urls.py

I'm having trouble linking to an app's urls.py file in Django

first_project urls.py

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

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

first_app urls.py

from django.conf.urls import url
from first_app import views

urlpatterns = [
    url('', views.index, name='index'),
]

Error

Django version 2.1.7, using settings 'first_project.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Not Found: /
[31/Mar/2019 14:28:54] "GET / HTTP/1.1" 404 2038

Upvotes: 1

Views: 67

Answers (2)

HuLu ViCa
HuLu ViCa

Reputation: 5452

You have to add a trailing slash to first_app url:

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

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

Upvotes: 1

JPG
JPG

Reputation: 88499

As per your URL configuration, you should've access the following url, /first_app/

Eg: http://localhost/first_app/

Upvotes: 0

Related Questions