Forums

Polls application page not found error.

Hi,

I enrolled for the course Django for Everybody and followed their instructions : https://www.dj4e.com/assn/dj4e_install.md to install Django and the polls application.

I continued to follow the steps outlined here: https://docs.djangoproject.com/en/3.0/intro/tutorial01/#creating-the-polls-app

I ran python3 manage.py check and reloaded the application in the web tab, however, navigating to jaromar.pythonanywhere.com/polls renders a page not found at /polls error.

I have gone through all the steps again and again and checked all the files, but I just don't get the polls view to display.

I read a lot of forum posts written by people running into the same issue, but there doesn't seem to be a solution. I hope you can help me solve the issue, so I can post it on the dj4e forum, giving people a better start than I'm having.

Kind regards,

Annet

What do you have in your urls.py?

Hi Giles,

Thanks for your reply.

In home/username/django_projects/mysite/mysite/urls.py I've got:

from django.contrib import admin
from django.urls import path

urlpatterns = [
    path('admin/', admin.site.urls),
]

In home/username/django_projects/mysite/polls/urls.py I've got:

from django.urls import path

from . import views

urlpatterns = [
    path('', views.index, name='index'),
]

In jaromar/files/var/www/username_pythonanywhere_com_wsgi.py I ve got:

import os
import sys

path = os.path.expanduser('~/django_projects/mysite')
if path not in sys.path:
    sys.path.insert(0, path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
from django.core.wsgi import get_wsgi_application
from django.contrib.staticfiles.handlers import StaticFilesHandler
application = StaticFilesHandler(get_wsgi_application())

The code in the wsgi file comes from: https://www.dj4e.com/assn/dj4e_install.md

I hope I provided you with sufficient information to help me solve the issue.

Kind regards,

Annet

[edit by admin: formatting]

Thanks for the details -- it looks like you must have skipped a step in that tutorial, then -- in order to serve a page at /polls/ in your site, you'll need to have a path object configured in at least one of your urls.py files that has that route as its first parameter, but right now you only have paths configured for "admin/" and "".

I have path configured for the polls app, and still 'no page found' error.

urlpatterns = [
path('admin/', admin.site.urls),
path('polls/', include('polls.urls')),

]

It looks like we've been discussing this over email too, so I'll respond there.