Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

368
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda