I am embarrassed, but I need help on Tutorial

I have followed the tutorial “Writing your first Django app, part 1 | Django documentation | Django”.
But I am stuck and don’t see my error.

I get this error:

I have this directory layout:

carsten@Oldman:~/projects/django4/mysite$ ll
insgesamt 24
drwxrwxr-x 4 carsten carsten 4096 Mär 29 11:25 ./
drwxrwxr-x 3 carsten carsten 4096 Mär 29 09:13 ../
-rw-r--r-- 1 carsten carsten    0 Mär 29 09:16 db.sqlite3
-rwxrwxr-x 1 carsten carsten  662 Mär 29 09:13 manage.py*
drwxrwxr-x 3 carsten carsten 4096 Mär 29 09:16 mysite/
drwxrwxr-x 3 carsten carsten 4096 Mär 29 11:24 polls/
-rw-rw-r-- 1 carsten carsten  170 Mär 29 11:25 urls.py

urls.py has this content:

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

urlpatterns = [
path(‘polls/’, include(‘polls.urls’)),
path(‘admin/’, admin.site.urls),
]

And under the folder polls this structure:

carsten@Oldman:~/projects/django4/mysite/polls$ ll
insgesamt 36
drwxrwxr-x 3 carsten carsten 4096 Mär 29 11:24 ./
drwxrwxr-x 4 carsten carsten 4096 Mär 29 11:25 ../
-rw-rw-r-- 1 carsten carsten   63 Mär 29 09:24 admin.py
-rw-rw-r-- 1 carsten carsten  142 Mär 29 09:24 apps.py
-rw-rw-r-- 1 carsten carsten    0 Mär 29 09:24 __init__.py
drwxrwxr-x 2 carsten carsten 4096 Mär 29 09:24 migrations/
-rw-rw-r-- 1 carsten carsten   57 Mär 29 09:24 models.py
-rw-rw-r-- 1 carsten carsten   60 Mär 29 09:24 tests.py
-rw-rw-r-- 1 carsten carsten  110 Mär 29 11:24 urls.py
-rw-rw-r-- 1 carsten carsten  127 Mär 29 11:22 views.py

with urls.py like this:

from django.urls import path

from . import views

urlpatterns = [
path(‘’, views.index, name=‘index’),
]

and views.py like this:

from django.http import HttpResponse


def index(request):
    return HttpResponse("Hello, world. You're at the polls index.")

The "runserver" command shows this:

carsten@Oldman:~/projects/django4/mysite$ python3 manage.py runserver
Watching for file changes with StatReloader
Performing system checks…

System check identified no issues (0 silenced).

You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run ‘python manage.py migrate’ to apply them.
March 29, 2022 - 09:25:15
Django version 4.0.3, using settings ‘mysite.settings’
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Not Found: /polls/
[29/Mar/2022 09:25:20] “GET /polls/ HTTP/1.1” 404 2095
Not Found: /polls/
[29/Mar/2022 09:26:14] “GET /polls/ HTTP/1.1” 404 2095
Not Found: /favicon.ico
[29/Mar/2022 09:26:14] “GET /favicon.ico HTTP/1.1” 404 2110

Can someone give me hint?

have you run python manage.py migrate?

You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.

Also make sure the polls app is added to your settings file

dunno but…

  1. add ‘polls’ to INSTALLED_APPS?
  2. try http://127.0.0.1:8000 and not http://localhost:8000/ ?

in all cases run migrate to get rid of that noise.

Hello chriswedgewood,

the tutorial says:

When I use the “migrate” the warnings dissapear, but the “polls” page is still not found.

Hello plopidou,

the tutorial doesn’t mention INSTALLED_APPS.
Where should I put that?

It doesn’t make a difference when I go to localhost or the 127.0.0.1.
The testpage shows, the admin page shows but the pollls not.

OMG! I got confused with the directory names.

I created the urls.py in the:

~/projects/django4/mysite

folder instead of:

~/projects/django4/mysite/mysite

That was my failure!
Thank you all for help.

ok cool :slight_smile:
check here anyway: Writing your first Django app, part 2 | Django documentation | Django

I was stuck on page one… now I can go forward :slight_smile:

1 Like