First Django App - views/urls problem

Hi all.

I am new to Django, and having major problems with my first app.

I am following both the Django Tutorial (polls app) and the First Django App on w3 Schools. Both are effectively the same idea, with different names for the project & app.

The problem occurs after I add the first view, then configure the urls in both the project and app urls.

I cannot, and I mean I cannot get the localhost:8000/polls/ app to work. I get the image of the rocket on the localhost:8000/ but it never works on the polls/ url.

I have tried over 20 times to set this project up from scratch in the last week, and I have followed the tutorial absolutely to the letter every single time. I would suggest that after trying c23-24 times, this cannot be an input error.

I can also see this issue seems to be common.

can anyone help? If I cant resolve this in the next week or so, I will have to walk away from Django and try a different language.

The error message I get is:

Using the URLConf defined in mysite.urls. django tried these url patterns in this order:

  1. admin/

The current path, polls/, didnt match any of these.

You’re missing a step somewhere along the way.

First, I suggest you work only from one source - don’t try to mix the two.

Please post your project file, along with your INSTALLED_APPS setting from your

Hi, and thanks for replying.

In polls/ I have this:

from django.urls import path

from . import views

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

and this is in the mysite/

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

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

The tutorial does not ask me to put anything in INSTALLED_APPS yet, however from reading various instances of the same problem, I have tried adding both of the following:


None of these combinations work.

There’s at least one section you’ve missed.

Review Step 2, Activating Models.

When you say:

Did that include going back to step 1 and starting from the beginning? Or are you just repeating step 3? If the latter, then I suggest you go back to step 1 and restart.

Hi there.

I havent missed section 2, its just that I havent got that far. The project isnt working on step 1, so I havent yet moved onto step 2.

I have been deleting the entire project and starting from scratch, following the tutorial, and things have broken down at the same point every time.

In terms of the steps I am taking:

1- django-admin startproject mysite
2- cd into mysite
3- python3 runserver
4- python3 startapp polls
5- write first view in
6- create file in polls
7- url path in polls/
8- url path in mysite/ (this is the inner mysite, not outer)
9- python3 runserver

And this is where is comes to a halt every time.

The part in the tutorial describes the issue perfectly:

If you get an error page here, check that you’re going to http://localhost:8000/polls/ and not http://localhost:8000/.

The entire problem im having is that there is nothing at localhost:8000/polls/ - its like that url doesnt exist. There is the standard congratulations page at localhost:8000/ - but there is no way of displaying the view from the polls/ file.

I’m sorry, I must have misread your original post. Somehow I got the idea you were on page 3.

Please copy/paste the entire content of your console screen where you’re running runserver, from the command line containing the runserver command through the 404 response received from the GET for /polls/

It may also help if you describe your environment in a little more detail. What operating system are you running? What versions of Python and Django are you using? Are you using an IDE for this?

One of the things to check is to ensure you don’t have an old copy of runserver still running when you’re trying to run your updated version.

Side note: When posting code here, enclose the code between lines of three backtick - ` characters. That means you will have a line of ```, then your code, then another line of ```. (When posting code from multiple files, it’s generally most useful to do this for each file individually.) This forces the forum software to keep your code properly formatted. This is also the recommended process when posting templates, error messages, and other pre-formatted text.