Path() got an unexpected keyword argument 'name'

I am new to Django and trying to set up my first app (home page) and I am currently following a tutorial. When i added in a new path into my urlspatterns list, and link it to the correct function, I get TypeError: path() got an unexpected keyword argument 'name'

Below is my code: App Directory urls.py

from argparse import Namespace
from importlib.resources import path
from unicodedata import name
from django.urls import re_path
from . import views

urlspatterns = [
    path('', views.index, name='index') # this is the main site path (home page)
]

views.py

from django.shortcuts import render
from django.http import HttpResponse

# Create your views here.

# This is form the home page
def index(request):
    return HttpResponse('<h1>Hey, Welcome</h1>')

project directory urls.py

"""cheatChecker URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/4.1/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, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('homapage/', include('homepage.urls'))
]

settings.py


INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'homepage',
]

Error that I get File "D:\Capstone_project\Capstone_project\cheatChecker\homepage\urls.py", line 8, in path('', views.index, name='index') # this is the main site path (home page) TypeError: path() got an unexpected keyword argument 'name'

I tried to takeout name and the error that i get is "valueerror empty module"

Any help would be appriciated!

It looks like you are importing the wrong path function you should import it from django.urls

from django.urls import path
Back to Top