[SOLVED] django - About page not loading, all other views load.
by maschelsea from LinuxQuestions.org on (#5KZS2)
This one is driving me crazy. I'm taking a Skillshare course on django. I'm trying to recreate perfectly what the instructor is doing on the screen. The two important files for this problem are urls.py and views.py.
Here's urls.py:
Code:"""tryjango URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from pages.views import home_view, contact_view, social_view, about_view
urlpatterns = [
path('', home_view, name='home'),
path('about/)', about_view),
path('social/', social_view),
path('contact/', contact_view),
path('admin/', admin.site.urls),
]And here's views.py:
Code:from django.http import HttpResponse
from django.shortcuts import render
# Create your views here.
def home_view(request, *args, **kwargs):
return render(request, 'home.html', {})
def contact_view(request, *args, **kwargs):
return HttpResponse("<h1>Contact Page</h1>")
def about_view(request, *args, **kwargs):
return HttpResponse('<h1>About page</h1>')
def social_view(request, *args, **kwargs):
return HttpResponse('<h1>Social Page</h1>')So far all my testing has worked. Except the about page. It gives me a 404, even though I spell it meticulously.
Code:Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/about/
Using the URLconf defined in tryjango.urls, Django tried these URL patterns, in this order:
[name='home']
about/)
social/
contact/
admin/
The current path, about/, 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.As you can see in my code above, the about page is coded the exact same as all the code around it. So why won't it map correctly?


Here's urls.py:
Code:"""tryjango URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from pages.views import home_view, contact_view, social_view, about_view
urlpatterns = [
path('', home_view, name='home'),
path('about/)', about_view),
path('social/', social_view),
path('contact/', contact_view),
path('admin/', admin.site.urls),
]And here's views.py:
Code:from django.http import HttpResponse
from django.shortcuts import render
# Create your views here.
def home_view(request, *args, **kwargs):
return render(request, 'home.html', {})
def contact_view(request, *args, **kwargs):
return HttpResponse("<h1>Contact Page</h1>")
def about_view(request, *args, **kwargs):
return HttpResponse('<h1>About page</h1>')
def social_view(request, *args, **kwargs):
return HttpResponse('<h1>Social Page</h1>')So far all my testing has worked. Except the about page. It gives me a 404, even though I spell it meticulously.
Code:Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/about/
Using the URLconf defined in tryjango.urls, Django tried these URL patterns, in this order:
[name='home']
about/)
social/
contact/
admin/
The current path, about/, 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.As you can see in my code above, the about page is coded the exact same as all the code around it. So why won't it map correctly?