I have setup part 1 of the django tutorial and am receiving the following 'Page not found (404)' error when trying to access the polls app:
Page not found (404) Request Method: GET Request URL: http://proto.slc.venturedata.com/polls/ Raised by: polls.views.index Using the URLconf defined in proto.urls, Django tried these URL patterns, in this order: 1. polls/ 2. admin/ The empty path didn't match any of these. You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
I'm using Django 2.2, Python 3.7, Apache 2.4.6, mod-wsgi 4.6.5.
I was able to complete the tutorial using the built in web server, but I started running into problems when I added Apache and mod-wsgi into the mix. Here is my code:
from django.contrib import admin from django.urls import include, path urlpatterns = [ path('polls/', include('polls.urls')), path('admin/', admin.site.urls), ]
from django.urls import path from . import views urlpatterns = [ path('', views.index, name='index'), ]
from django.http import HttpResponse def index(request): return HttpResponse("Hello, world. You're at the polls index.")
The only thing changed in the settings.py was the TIMEZONE. Everything else is set to defaults.
Something seems to be up with the urls and path matching. The url I used (proto.slc.venturedata.com/polls/) should match the 'polls/' path, but the error message says that the path is empty.
In experimenting I found that I didn't receive an error if I modified proto/urls.py by replacing the 'polls/' path with an empty path: ''.
urlpatterns = [ path('', include('polls.urls')), path('admin/', admin.site.urls), ]
Am I missing something?
Including the non-default Apache configuration since the problems started after I configured Django to use Apache as the webserver.
ServerName 10.0.10.249:80 <Directory /> AllowOverride none Require all denied </Directory> DocumentRoot "/var/www/html" WSGIPythonPath /var/local/www/proto/ <VirtualHost *:80> DocumentRoot "/var/local/www/proto" ServerName proto.slc.venturedata.com <Directory "/var/local/www/proto"> Require all granted </Directory> WSGIScriptAlias /polls /var/local/www/proto/proto/wsgi.py </VirtualHost>