hello_world() 缺少 1 个必需的位置参数:'request'

hello_world() missing 1 required positional argument: 'request'

请协助找出此错误的解决方案。

课程/views.py

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

from .models import Course

def course_list(request):
    courses = Course.objects.all()
    return render(request, 'courses/course_list.html',{'courses':courses})

admin/views.py

from django.shortcuts import render

def hello_world(request):
    return render(request, 'home.html')

admin urls.py

from django.contrib import admin
from django.urls import path
from courses import views
from django.conf.urls import include
from . import views

urlpatterns = [
    path('admin/', admin.site.urls),
    path('admin/', views.hello_world()),
    path('courses/', include('courses.urls')),
    path('courses/', views.course_list(), name='listofcourses'),
]

课程/urls.py

from django.urls import path
from . import views

urlpatterns=[
path('',views.course_list, name="listofcourses"),
]

现在在 运行 服务器上,我收到此错误

hello_world() 缺少 1 个必需的位置参数:'request'

我希望在 127.0.0.1:8000 的 运行 服务器上发布主页,在 127.0.0.1:8000/courses 上发布课程页面

提前致谢

您正在调用(执行)urls 中的视图,这是不应该的。你可以这样做:

path('hello-world/', views.hello_world),   # don't use 'admin/' because you already have url configured against this path.