Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

184
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!