0

I am following the Django Tutorial but I am getting a error when trying to load the welcome page, just after starting the server I did this tutorial in other pc and I did not have any problem.

Using: Windows 7 / Djando 1.9 / Python 3.4.5

1 - I started the project 2 - python manage.py runserver enter image description here

3 - When I access the page:

enter image description here

4 - The I got on cmd

enter image description here

I have already tried hundred of ports, ips, firewall disabling, django 1.10 ...

5 - urls.py

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    url(r'^polls/', include('polls.urls')),
    url(r'^admin/', admin.site.urls),
]
Lorenzo Simonassi
  • 495
  • 1
  • 5
  • 14
  • What does your view look like? It seems like you're not returning anything – kylieCatt Aug 12 '16 at 19:37
  • So, I am following the tutorial https://docs.djangoproject.com/en/1.9/intro/tutorial01 and until the moment when it asks to run the server it does not talk anything about the views. It should be automatic to load the django welcome view .. But if you want i cant post my urls.py. I did not change any code. – Lorenzo Simonassi Aug 12 '16 at 19:48
  • 3
    Do you visit http://127.0.0.1:8000/? Do you pointed out port? – M.Void Aug 12 '16 at 19:52
  • Try with and without slash. Make sure you have a route defined for '/'. Make sure your test view returns an HttpResponse instance. – JulienD Aug 12 '16 at 20:27
  • @JulienD I tried. Even with the polls view (from the tutorial) it does not work. When I visit localhost:8000/polls/ I get: The localhost page isn’t working localhost didn’t send any data. ERR_EMPTY_RESPONSE – Lorenzo Simonassi Aug 12 '16 at 20:33
  • Try to access your app with curl instead. Also, again it really looks like your urls.py is missing a line for '/', or does not have an appropriate controller for that route. You can also try a different port, in case this one is already use by another misconfigured service that has not view for '/', like a previous version of your own app that you did not stop. – JulienD Aug 12 '16 at 20:57
  • @JulienD, I posted mine urls.py. Do you see something wrong? Sorry, but I am just starting with django. – Lorenzo Simonassi Aug 12 '16 at 21:08
  • It seems you have a different problem as well, but just so you know: if you define any urls (besides the `admin/` urls), you won't see the "Welcome to Django" page. Since you've added urls for the `polls` app, you won't see that page. – knbk Aug 12 '16 at 21:18
  • @knbk, okay. I did everything again. I am not go forward with the polls app. First I will try to see Django Welcome Page. – Lorenzo Simonassi Aug 12 '16 at 21:24
  • I tried everything and nothing has worked. Do you think it might be something about firewall? browser settings? – Lorenzo Simonassi Aug 13 '16 at 20:24

2 Answers2

2

The problem is, you have no router or view defined for "/". All valid paths would be http://127.0.0.1/polls/* and http://127.0.0.1/admin/*.

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    # load urls of an app and define there more detailed
    url(r'^polls/', include('polls.urls')),
    url(r'^admin/', admin.site.urls),
    # load specific view in an app
    url(r'^your_test_view','my_app.views.my_view', name="my_view"),
    url(r'^$','my_app.views.my_home_view', name="home"),
]
dojon
  • 36
  • 1
1

The problem was that you forgot to makemigrations and then migrate.

py manage.py makemigration

py manage.py migrate

Lorenzo SC
  • 175
  • 1
  • 15