Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django.urls.exceptions.NoReverseMatch: Reverse for 'home' not found. 'home' is not a valid view function or pattern name

I have a problem where my url is seen as an invalid url. None of my URLS are working for my Django Application. I have made the mistake of using the same secret key that I used for another application. Here is a picture of my error message, url page, and my views.

Error Message

urls.py

views.py

from django.shortcuts import render
from home.models import Products

#This is the store view
def home(request):
    return render(request,'home.html')

#This is the About Us page view
def AboutUs(request):
    return render(request,'AboutUs.html')

#This is the Long Arm Services View
def LongArmServices(request):
    return render(request,'LongArmServices.html')

#This is the product View
def product(request):
    return render(request,'product.html')

urls.py:

from django.urls import path
from . import views
from django.http import HttpResponse


app_name='home'

urlpatterns = [
    path('',views.home,name='home'),
    path('about_us/',views.AboutUs,name='AboutUs'),        path('long_arm_services/',views.LongArmServices,name='LongArmServices'),
    path('product/',views.product,name='product'),
]
like image 867
James Francies Avatar asked Dec 30 '25 03:12

James Francies


1 Answers

Your urls.py specify an app_name = 'home', so that means you need to prefix the name of the view with the app_name and a colon (:). So you should rewrite the marked part in the template to:

href="{% url 'home:home' %}"
like image 101
Willem Van Onsem Avatar answered Jan 01 '26 18:01

Willem Van Onsem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!