# Django Tutorial Will not work

**URL:** <https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392>\
**Category:** Getting Started\
**Created:** [August 26, 2023, 12:26am UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392 "2023-08-26T00:26:13Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex1](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/alex1/32/15602_2.png) [@Alex1](https://forum.djangoproject.com/u/Alex1)\
**Post date:** [August 26, 2023, 12:26am UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392/1 "2023-08-26T00:26:13Z")

</div>

I am following the tutorial, and it is not working no matter what I try. I am at the end of the 1st part of the tutorial, but every time I try running [http://127.0.0.1:8000/polls](http://127.0.0.1:8000/polls) it just does not work and says admin is the only URL that shows. I have tried many fixes from other posts, but it is not working.  
mysite/mysite/urls has the code from the tutorial, and i filled out polls/views and polls/urls. I have deleted all my files and restarted the tutorial a few times, but it is not working. Here is the code I have:  
polls/views.py:

# Create your views here.

from django.http import HttpResponse

def index(request):  
return HttpResponse(“Hello, world. You’re at the polls index.”)  
polls/urls.py:  
from django.urls import path

from . import views

urlpatterns = [  
path(“”, views.index, name=“index”),  
]  
my site urls:  
from django.contrib import admin  
from django.urls import include, path

urlpatterns = [  
path(“polls/”, include(“polls.urls”)),  
path(“admin/”, admin.site.urls),  
]

 ![path](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/f/f73be7048608215342d9bbae2a78df633223273f.png)  
idk if that works but it shows how the files are placed. I do not know what else to try so any help would be appreciated. Thank you

---

<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:** [August 26, 2023, 12:36am UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392/2 "2023-08-26T00:36:33Z")

</div>

Your url path includes the trailing slash for the url `polls/`, but you aren’t showing it in the url that you’re saying that you are trying. Yes, `polls` and `polls/` are two different urls.

---

<div class="post-metadata">

**Author:** ![Alex1](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/alex1/32/15602_2.png) [@Alex1](https://forum.djangoproject.com/u/Alex1)\
**Post date:** [August 26, 2023, 12:37am UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392/3 "2023-08-26T00:37:36Z")

</div>

Sorry that was unclear, I have tried polls/ as well, but neither seem to work, and when on the 404 error page it only says that admin/ is a URL present it does not even show 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:** [August 26, 2023, 12:45am UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392/4 "2023-08-26T00:45:09Z")

</div>

What OS are you working on? Have you stopped and restarted the server? What is the ROOT\_URLCONF setting in your settings.py file?

---

<div class="post-metadata">

**Author:** ![Alex1](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/alex1/32/15602_2.png) [@Alex1](https://forum.djangoproject.com/u/Alex1)\
**Post date:** [August 26, 2023, 1:03am UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392/5 "2023-08-26T01:03:32Z")

</div>

Windows. My root\_urlconf just says mysite.urls

---

<div class="post-metadata">

**Author:** ![augustogoulart](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/augustogoulart/32/930_2.png) [@augustogoulart](https://forum.djangoproject.com/u/augustogoulart)\
**Post date:** [August 26, 2023, 2:56am UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392/6 "2023-08-26T02:56:14Z")

</div>

I’ve to say I’m pretty intrigued about that error. I just did that first section of the tutorial on two UNIX machines, and they both worked. Unfortunately, I don’t have a Windows machine at hand right now.

Can you put that code on a public repository and share the link?

---

<div class="post-metadata">

**Author:** ![foxy4096](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/foxy4096/32/29065_2.png) [@foxy4096](https://forum.djangoproject.com/u/foxy4096)\
**Post date:** [August 26, 2023, 5:00am UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392/7 "2023-08-26T05:00:26Z")

</div>

Have you added the `polls` app in `INSTALLED_APPS` in `settings.py`

---

<div class="post-metadata">

**Author:** ![foxy4096](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/foxy4096/32/29065_2.png) [@foxy4096](https://forum.djangoproject.com/u/foxy4096)\
**Post date:** [August 26, 2023, 5:13am UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392/8 "2023-08-26T05:13:50Z")

</div>

Wow this is weird, but I just tried the same thing on my computer without adding the `polls` app in the `INSTALLED_APPS` in the `settings.py` and this is working

---

<div class="post-metadata">

**Author:** ![foxy4096](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/foxy4096/32/29065_2.png) [@foxy4096](https://forum.djangoproject.com/u/foxy4096)\
**Post date:** [August 26, 2023, 5:22am UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392/9 "2023-08-26T05:22:30Z")

</div>

Mr. Ken, will not django redirects `polls` to `polls/`

I’ve just checked that going to `localhost:8000/poll` redirects me to `localhost:8000/polls/`

```sh
C:\Users\home\Desktop\mysite>curl localhost:8000/polls -v
* Trying 127.0.0.1:8000...
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET /polls HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/8.0.1
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Date: Sat, 26 Aug 2023 05:21:35 GMT
< Server: WSGIServer/0.2 CPython/3.10.9
< Content-Type: text/html; charset=utf-8
< Location: /polls/
< X-Content-Type-Options: nosniff
< Referrer-Policy: same-origin
< Cross-Origin-Opener-Policy: same-origin
< Connection: close
<
* Closing connection 0

```

---

<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:** [August 26, 2023, 8:43am UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392/10 "2023-08-26T08:43:30Z")

</div>

It’s a configuration setting, it doesn’t “automatically “ do that. So without diving into those settings, I don’t assume it’s going to be there. See [Settings | Django documentation | Django](https://docs.djangoproject.com/en/4.2/ref/settings/#append-slash)

---

<div class="post-metadata">

**Author:** ![foxy4096](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/foxy4096/32/29065_2.png) [@foxy4096](https://forum.djangoproject.com/u/foxy4096)\
**Post date:** [August 26, 2023, 9:08am UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392/11 "2023-08-26T09:08:05Z")

</div>

But in the global settings the `APPEND_SLASH` is already set to true

---

<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:** [August 26, 2023, 9:18am UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392/12 "2023-08-26T09:18:57Z")

</div>

It also requires the common middleware to be installed. Yes, it’s also a default for startproject, but would need to be verified.

---

<div class="post-metadata">

**Author:** ![Alex1](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/alex1/32/15602_2.png) [@Alex1](https://forum.djangoproject.com/u/Alex1)\
**Post date:** [August 26, 2023, 2:58pm UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392/13 "2023-08-26T14:58:23Z")

</div>

I will do that now let me get one up

---

<div class="post-metadata">

**Author:** ![Alex1](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/alex1/32/15602_2.png) [@Alex1](https://forum.djangoproject.com/u/Alex1)\
**Post date:** [August 26, 2023, 3:00pm UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392/14 "2023-08-26T15:00:47Z")

</div>

[https://github.com/Alex-Aron/djangotutorial](https://github.com/Alex-Aron/djangotutorial)  
That link has my files

---

<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:** [August 27, 2023, 12:23am UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392/15 "2023-08-27T00:23:57Z")

</div>

The `mysite.urls` file you posted in that repo only has the `admin` entry. It does not have the `polls` entry. Your `polls.urls` file is also empty.

---

<div class="post-metadata">

**Author:** ![Alex1](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/alex1/32/15602_2.png) [@Alex1](https://forum.djangoproject.com/u/Alex1)\
**Post date:** [August 27, 2023, 4:46pm UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392/16 "2023-08-27T16:46:42Z")

</div>

Oh my god. The issue was that the files I was typing was not properly saving when I hit control S, so when I put it to git it just pushed empty files. All the code I typed was not saved that’s why nothing was working.

---

<div class="post-metadata">

**Author:** ![NoahP4](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/noahp4/32/18086_2.png) [@NoahP4](https://forum.djangoproject.com/u/NoahP4)\
**Post date:** [December 31, 2023, 6:18pm UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392/17 "2023-12-31T18:18:32Z")

</div>

Oh man I just want to thank you for taking the time to post that you have no idea how much you have helped me i have been going crazy for 5 hours not knowing why none of my code was running turns out I wasnt saving anything lmao hadnt even thought of that until I read you comment

---

<div class="post-metadata">

**Author:** ![polyblendsolutions](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/polyblendsolutions/32/21973_2.png) [@polyblendsolutions](https://forum.djangoproject.com/u/polyblendsolutions)\
**Post date:** [June 14, 2024, 9:05am UTC](https://forum.djangoproject.com/t/django-tutorial-will-not-work/23392/18 "2024-06-14T09:05:55Z")

</div>

This error is in index.html.  
You have to change code to original code.  
There causes by reverse error.  
It works well.
