Solution 1 :

Firstly you shouldn’t access page by .html it should be accessed by url only.

You are already using shop/ here:

path('shop/', include('shop.urls')),

So you should avoid using it in your sub-urls below.

Else you will have to access by shop/shop/cart/ instead of shop/cart/.

Change the urls as below:

urlpatterns = [
    path("", views.index, name="ShopHome"),
    path("cart/", views.cart, name="Cart"),
    path("checkout/", views.checkout, name="Checkout"),
    path("contact/",, name="ContactUs"),
    path("register/", views.register, name="Register"),
    path("product_details/", views.product_details, name="ProductDetails"),
    path("products/", views.products, name="Products"),

This should work fine for you.

Problem :

*I have creted a shop app now in it *


from django.urls import path
from . import views

urlpatterns = [
    path("", views.index, name="ShopHome"),
    path("shop/cart/", views.cart, name="Cart"),
    path("shop/checkout/", views.checkout, name="Checkout"),
    path("shop/contact/",, name="ContactUs"),
    path("shop/register/", views.register, name="Register"),
    path("shop/product_details/", views.product_details, name="ProductDetails"),
    path("shop/products/", views.products, name="Products"),

the main project

from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    path('shop/', include('shop.urls')),

]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

from django.shortcuts import render

# Create your views here.
from django.http import HttpResponse

def index(request):
    return render(request, 'shop/index.html')

def register(request):
    return render(request, 'shop/register.html')

def contact(request):
    return render(request, 'shop/contact.html')

def products(request):
    return render(request, 'shop/products.html')

def product_details(request):
    return render(request, 'shop/product_details.html')

def cart(request):
    return render(request, 'shop/cart.html')

def checkout(request):
    return render(request, 'shop/checkout.html')

from django.db import models

# Create your models here.

class Product(models.Model):
    name = models.CharField(max_length=300)
    slug = models.SlugField(max_length=150)
    description = models.TextField()
    image = models.ImageField(upload_to='shop/images', default='')
    manufacturer = models.CharField(max_length=300, blank=True)
    price_in_dollars = models.DecimalField(max_digits=6, decimal_places=2)

    def __str__(self):
        return the installed apps part



from django.apps import AppConfig

class ShopConfig(AppConfig):
    name = 'shop'

from django.contrib import admin

# Register your models here.

from . models import Product

*the html is not loading in the browser its showing *

Page not found (404)
Request Method:     GET
Request URL:

Using the URLconf defined in mac.urls, Django tried these URL patterns, in this order:

    shop/ [name='ShopHome']
    shop/ cart/ [name='Cart']
    shop/ checkout/ [name='Checkout']
    shop/ contact/ [name='ContactUs']
    shop/ register/ [name='Register']
    shop/ product_details/ [name='ProductDetails']
    shop/ products/ [name='Products']

The current path, shop/products.html, 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 ahve tried many other htmls but only the main /shop page is appearing no other url is working like /shop/product or /shop/cart non of them are working ive been trying to fic it for a long time now


Comment posted by Astik Anand

@AntonyKJohn, do let me know if this works for you.

Comment posted by

it did not work bro it shows the same error even after trying the method you suggested by

Comment posted by Astik Anand

@AntonyKJohn, I missed the question info, can you check the updated answer and let me know if this works for you.

Comment posted by Astik Anand

@AntonyKJohn, glad it helped.