# polls app Page not found (404)

**URL:** <https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652>\
**Category:** Getting Started\
**Created:** [May 12, 2022, 5:34am UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652 "2022-05-12T05:34:33Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarcPozzo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/marcpozzo/32/8477_2.png) [@MarcPozzo](https://forum.djangoproject.com/u/MarcPozzo)\
**Post date:** [May 12, 2022, 5:34am UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/1 "2022-05-12T05:34:33Z")

</div>

Hello I am try to follow the official tutorial of django and try to add the page /polls . I am a totally beguinner on django .  
Could you please help me ?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/7/757c45b2dfcccff3145de7a90d67df27d7ee67e1.png)

mysite/  
urls.py

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

urlpatterns = [  
path(‘’, include(‘pages.urls’)),  
path(‘polls/’, include(‘polls.urls’)),  
path(‘admin/’, admin.site.urls),  
path(‘’, lambda request: HttpResponse(‘the cow jumped over the moon’)),  
]

These are my files:

mysite/mysite/

settings.py

> from pathlib import Path
> 
> # Build paths inside the project like this: BASE\_DIR / ‘subdir’.
> 
> BASE\_DIR = Path( **file** ).resolve().parent.parent
> 
> # SECURITY WARNING: keep the secret key used in production secret!
> 
> SECRET\_KEY = ‘django-insecure-5@od4ay%v5eatrbi(ezo2fr0jmswemsmx!1w(399#f!e6cbni7’
> 
> # SECURITY WARNING: don’t run with debug turned on in production!
> 
> DEBUG = True
> 
> ALLOWED\_HOSTS =
> 
> # Application definition
> 
> INSTALLED\_APPS = [  
> ‘polls.apps.PollsConfig’,  
> ‘django.contrib.admin’,  
> ‘django.contrib.auth’,  
> ‘django.contrib.contenttypes’,  
> ‘django.contrib.sessions’,  
> ‘django.contrib.messages’,  
> ‘django.contrib.staticfiles’,  
> ]
> 
> MIDDLEWARE = [  
> ‘django.middleware.security.SecurityMiddleware’,  
> ‘django.contrib.sessions.middleware.SessionMiddleware’,  
> ‘django.middleware.common.CommonMiddleware’,  
> ‘django.middleware.csrf.CsrfViewMiddleware’,  
> ‘django.contrib.auth.middleware.AuthenticationMiddleware’,  
> ‘django.contrib.messages.middleware.MessageMiddleware’,  
> ‘django.middleware.clickjacking.XFrameOptionsMiddleware’,  
> ]
> 
> ROOT\_URLCONF = ‘mysite.urls’
> 
> TEMPLATES = [  
> {  
> ‘BACKEND’: ‘django.template.backends.django.DjangoTemplates’,  
> ‘DIRS’: ,  
> ‘APP\_DIRS’: True,  
> ‘OPTIONS’: {  
> ‘context\_processors’: [  
> ‘django.template.context\_processors.debug’,  
> ‘django.template.context\_processors.request’,  
> ‘django.contrib.auth.context\_processors.auth’,  
> ‘django.contrib.messages.context\_processors.messages’,  
> ],  
> },  
> },  
> ]
> 
> WSGI\_APPLICATION = ‘mysite.wsgi.application’

> DATABASES = {  
> ‘default’: {  
> ‘ENGINE’: ‘django.db.backends.sqlite3’,  
> ‘NAME’: BASE\_DIR / ‘db.sqlite3’,  
> }  
> }
> 
> AUTH\_PASSWORD\_VALIDATORS = [  
> {  
> ‘NAME’: ‘django.contrib.auth.password\_validation.UserAttributeSimilarityValidator’,  
> },  
> {  
> ‘NAME’: ‘django.contrib.auth.password\_validation.MinimumLengthValidator’,  
> },  
> {  
> ‘NAME’: ‘django.contrib.auth.password\_validation.CommonPasswordValidator’,  
> },  
> {  
> ‘NAME’: ‘django.contrib.auth.password\_validation.NumericPasswordValidator’,  
> },  
> ]

> LANGUAGE\_CODE = ‘en-us’
> 
> TIME\_ZONE = ‘UTC’
> 
> USE\_I18N = True
> 
> USE\_TZ = True
> 
> DEFAULT\_AUTO\_FIELD = ‘django.db.models.BigAutoField’

views.py

> from django.shortcuts import render
> 
> # Create your views here.
> 
> from django.http import HttpResponse
> 
> def index(request):  
> return HttpResponse(“Hello, world. You’re at the polls index.”)

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [May 12, 2022, 9:44pm UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/2 "2022-05-12T21:44:40Z")

</div>

First, a side note - when posting code or errors here, surround each file or traceback with lines of three backtick - ` characters. this means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted.

Notice that you entered a url without the trailing slash, while the path definition in your urls.py file has the trailing slash.

Also, what are the contents of the urls.py file in your polls directory?

---

<div class="post-metadata">

**Author:** ![MarcPozzo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/marcpozzo/32/8477_2.png) [@MarcPozzo](https://forum.djangoproject.com/u/MarcPozzo)\
**Post date:** [May 13, 2022, 6:10am UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/3 "2022-05-13T06:10:26Z")

</div>

mysite/polls/urls.py

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/8/85a441b6496d483ee9b3cdc907855a799b10fbf9.png)

sorry for the missing part and the bad presentation. I wanted to modify my post but when I tried it was not possible. I tried again in this answer to paste my code but it didn’t work neither that is why i gave you the screenshot.

Do you need more information ?  
Thank you in advance for your help.

---

<div class="post-metadata">

**Author:** ![qvisty](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/qvisty/32/4818_2.png) [@qvisty](https://forum.djangoproject.com/u/qvisty)\
**Post date:** [May 13, 2022, 6:46am UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/4 "2022-05-13T06:46:29Z")

</div>

Can we see your project lvl urls.py file?

---

<div class="post-metadata">

**Author:** ![MarcPozzo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/marcpozzo/32/8477_2.png) [@MarcPozzo](https://forum.djangoproject.com/u/MarcPozzo)\
**Post date:** [May 13, 2022, 7:50am UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/5 "2022-05-13T07:50:49Z")

</div>

what does mean lvl ?

---

<div class="post-metadata">

**Author:** ![qvisty](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/qvisty/32/4818_2.png) [@qvisty](https://forum.djangoproject.com/u/qvisty)\
**Post date:** [May 13, 2022, 8:41am UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/6 "2022-05-13T08:41:20Z")

</div>

Level. Sorry 🤷  
The urls.py file in your project. Not the one in the app folder

---

<div class="post-metadata">

**Author:** ![MarcPozzo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/marcpozzo/32/8477_2.png) [@MarcPozzo](https://forum.djangoproject.com/u/MarcPozzo)\
**Post date:** [May 13, 2022, 9:04am UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/7 "2022-05-13T09:04:49Z")

</div>

Thank you to answer to my questions 🙂

This one ?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/b/b5ad160fa32b4c64568da42e4696cb8a568b3539.png)

> from django.contrib import admin  
> from django.urls import include, path
> 
> urlpatterns = [  
> path(‘’, include(‘pages.urls’)),  
> path(‘polls/’, include(‘polls.urls’)),  
> path(‘admin/’, admin.site.urls),  
> path(‘’, lambda request: HttpResponse(‘the cow jumped over the moon’)),  
> ]

---

<div class="post-metadata">

**Author:** ![qvisty](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/qvisty/32/4818_2.png) [@qvisty](https://forum.djangoproject.com/u/qvisty)\
**Post date:** [May 13, 2022, 9:47am UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/8 "2022-05-13T09:47:00Z")

</div>

I had a similar problem once. Clearing the browser data, cookies and such worked.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [May 13, 2022, 10:46am UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/9 "2022-05-13T10:46:28Z")

</div>

Did you try entering the url with the trailing slash?

And what is the content of the polls/apps.py file?

Please do not post images of code here. They’re not readable on all devices, and they cannot be searched or quoted for future reference. When posting code or errors here, surround each file or traceback with lines of three backtick - ` characters. this means you’ll have a line of \```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted. Note: The lines of ``` before and after the code must be lines on their own.  
Example:

````auto
# The line above this is ```
def some_function():
    return True
# The line after this is ```

````

---

<div class="post-metadata">

**Author:** ![MarcPozzo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/marcpozzo/32/8477_2.png) [@MarcPozzo](https://forum.djangoproject.com/u/MarcPozzo)\
**Post date:** [May 13, 2022, 1:10pm UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/10 "2022-05-13T13:10:52Z")

</div>

Do you mean type that as an url ?  
[http://127.0.0.1:8000/polls/](http://127.0.0.1:8000/polls/)

---

<div class="post-metadata">

**Author:** ![MarcPozzo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/marcpozzo/32/8477_2.png) [@MarcPozzo](https://forum.djangoproject.com/u/MarcPozzo)\
**Post date:** [May 13, 2022, 1:12pm UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/11 "2022-05-13T13:12:45Z")

</div>

polls/apps.py

> from django.apps import AppConfig
> 
> class PollsConfig(AppConfig):  
> default\_auto\_field = ‘django.db.models.BigAutoField’  
> name = ‘polls’

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [May 13, 2022, 1:51pm UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/12 "2022-05-13T13:51:07Z")

</div>

Yes, did you try that?

---

<div class="post-metadata">

**Author:** ![MarcPozzo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/marcpozzo/32/8477_2.png) [@MarcPozzo](https://forum.djangoproject.com/u/MarcPozzo)\
**Post date:** [May 13, 2022, 2:18pm UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/13 "2022-05-13T14:18:27Z")

</div>

Yes I did.  
I also removed all my cookies.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [May 13, 2022, 2:23pm UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/14 "2022-05-13T14:23:20Z")

</div>

How are you running your application? (Are you using runserver?)

It looks like you might be running this on Windows, is that correct?

Are you restarting the server after making your changes?

---

<div class="post-metadata">

**Author:** ![MarcPozzo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/marcpozzo/32/8477_2.png) [@MarcPozzo](https://forum.djangoproject.com/u/MarcPozzo)\
**Post date:** [May 13, 2022, 2:38pm UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/15 "2022-05-13T14:38:27Z")

</div>

I use a window  
I type on anaconda prompt

> python manage.py runserver

sometimes

> python manage.py migrate  
> python manage.py runserver

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [May 13, 2022, 2:43pm UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/16 "2022-05-13T14:43:32Z")

</div>

Are you stopping and restarting runserver every time you make changes to your code? Or are you verifying that runserver is recognizing that the code has been changed and is restarting itself?

---

<div class="post-metadata">

**Author:** ![MarcPozzo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/marcpozzo/32/8477_2.png) [@MarcPozzo](https://forum.djangoproject.com/u/MarcPozzo)\
**Post date:** [May 13, 2022, 3:08pm UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/17 "2022-05-13T15:08:29Z")

</div>

I am stopping and restarting runserver every time i make changes to my code with ctr+c and then

> python manage.py runserver

in anaconda prompt

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [May 13, 2022, 3:52pm UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/18 "2022-05-13T15:52:13Z")

</div>

I’m kinda stumped here. I can’t think of any reasonable explanation for the behavior you’re describing, unless you’ve got some mixup with your directories and you’re editing a different directory than what you’re running with runserver.

Let’s try to clarify your directory structure.

What you should have:

```nohighlight
mysite
  |--- mysite
       |--- settings.py
       |--- urls.py
       |--- (other files)
  |--- polls
       |--- apps.py
       |--- views.py
       |--- models.py
       |--- urls.py

```

There should _not_ be a polls directory inside the “inner” mysite directory

---

<div class="post-metadata">

**Author:** ![MarcPozzo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/marcpozzo/32/8477_2.png) [@MarcPozzo](https://forum.djangoproject.com/u/MarcPozzo)\
**Post date:** [May 13, 2022, 4:17pm UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/19 "2022-05-13T16:17:39Z")

</div>

```auto
mysite
  db.sqlite3
  manage.py
  urls.py
  |--- mysite
       |--- settings.py
       |--- urls.py
       |--- __init__.py
       |---asgi.py
       |---wsgi.py
  |--- polls
       |--- apps.py
       |--- views.py
       |--- models.py
       |--- urls.py
       |--- test.py
       |--- admin.py
       |--- __init__.py
       |---migration
          |--- ...

```

Should I move someting ?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [May 13, 2022, 5:21pm UTC](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652/20 "2022-05-13T17:21:53Z")

</div>

You don’t need to move anything, but you might want to remove that first `urls.py` file (the one directly below `manage.py`) - it’s presence may be confusing. Your root urls are in the inner mysite directory as specified in your settings.py file.

If you’ve made your changes to that outer urls.py file, then you have edited the wrong file.

[Next page](https://forum.djangoproject.com/t/polls-app-page-not-found-404/13652.md?page=2)
