我正在尝试在pycharm上运行manage.py runserver并返回属性错误
File "C:\Users\user\PycharmProjects\Diabetes Prediction\Diabetes_prediction\Diabetes_Prediction\urls.py", line 23, in <mod
ule>
path("", views.home),
^^^^^^^^^^
AttributeError: module 'Diabetes_Prediction.views' has no attribute 'home'
我预计该项目能够运行
这通常意味着视图模块内没有“home”函数或类。
要解决此问题,您应该检查 Diabetes_Prediction/views.py 文件并确保它包含名为“home”的函数或类。这是您的views.py 的一般示例:
# Diabetes_Prediction/views.py
from django.shortcuts import render
def home(request):
# Your view logic goes here
return render(request, 'home.html') # Adjust the template name as needed
希望对您有帮助。
检查 Diabetes_Prediction 中的views.py 文件是否定义了主类,并检查 urls.py 路径是否正确 如果views.py中没有主类,则创建它
您没有 Home 方法或类 在 view.py 文件中请正确检查