I'm encountering an issue with my Django project. I've set up views and URLs for several pages like 'landing', 'chat', 'impressum', 'sales', 'team', and 'user'. However, when I try to access these pages in the browser, I receive a 404 error indicating that the pages cannot be found. Here's the relevant code I've implemented:
from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.landing, name='landing'),
path('chat/', views.chat, name='chat'),
path('impressum/', views.impressum, name='impressum'),
path('sales/', views.sales, name='sales'),
path('team/', views.team, name='team'),
path('user/', views.user, name='user'),
]
# views.py
from django.shortcuts import render
def landing(request):
return render(request, 'landing.html')
def chat(request):
return render(request, 'chat.html')
def impressum(request):
return render(request, 'impressum.html')
def sales(request):
return render(request, 'sales.html')
def team(request):
return render(request, 'team.html')
def user(request):
return render(request, 'user.html')
# settings.py
import os
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'teacherassistant/templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
Despite correctly defining URLs and views, I'm unable to render the respective HTML templates for each page as intended. It seems like there's an issue with how Django is handling the routing.

Your app name appears to be
teacherassistant. First, make sure this is included in your INSTALLED_APPS list in yoursettings.py.Then open your project level urls.py which is automatically created in your project directory
django_teacherassistant\urls.pyand enter the following code:Then in your app directory i.e.
teacherassistant, create an app urls.py file and enter the following code:Note: you have to create your app urls.py file but the project urls.py file is automatically created for you. Please do not mix up the two! See Django URLs Path.