Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
Page not found with Django (404)

In my django project, when I access localhost:8000 it says:

  Page not found (404)
  Request Method:   GET
  Request URL:  http://localhost:8000/

The urls.py is:

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

  urlpatterns = [
      url(r'^admin/', admin.site.urls),
      url(r'^polls/', include('polls.urls', namespace="polls")),
  ]

The polls urls.py is:

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

  urlpatterns = [
      url(r'^$', views.index, name='index'),
      url(r'^(?P<question_id>\d+)/$', views.detail, name='detail'),
      url(r'^(?P<question_id>\d+)/vote/$', views.vote, name='vote'),
      url(r'^(?P<question_id>\d+)/results/$', views.results, name='results'),
      url(r'^admin/', admin.site.urls),
  ]

The Django version is 1.10. Can anyone help me identify the problem? Thanks in advance.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You do not have a route for / it seems, so http://localhost:8000/ does not get you anywhere.

You wrote url(r'^polls/', include('polls.urls', namespace="polls")), in urls.py so all the routes defined in polls.urls are to be prefixed with polls/.

You may actually want to go to http://localhost:8000/polls/ (notice the polls/, because the route you defined as index is listed in the polls app.

Had you wanted to route your polls index to your url root, you should change urls.py to something like

urlpatterns = [
    url(r'^', include('polls.urls', namespace="polls")),
    url(r'^admin/', admin.site.urls),
]

and the forget about the polls/ part in the urls.

over 4 years ago · Santiago Trujillo Relatório

0

In main urls.py change

from

url(r'^polls/', include('polls.urls', namespace="polls")),

to

url(r'^$', include('poll.urls')),
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda