设置Django时出错。类“werken”没有对象

2024-05-08 12:41:19 发布

您现在位置:Python中文网/ 问答频道 /正文

[我的模型.py][1][models.py][2]``` 从django.shortcuts导入渲染、重定向、获取对象或404 从.模型导入Werken

在此处创建视图

def home(请求): werken=werken.objects return render(请求'werken/werken.html',{'werken':werken})

def详细信息(请求,werken\U id): werk=get\u object\u或\u 404(Werken,pk=Werken\u id) return render(请求'werken/detail.html',{'werk':werk})

你知道吗{ “resource”:“/c:/Users/jarmo/OneDrive/Bureaublad/project challenge/portfolio project/werken/views.py”, “owner”:“python”, “code”:“无会员”, “严重性”:8, “message”:“类'Werken'没有'objects'成员”, “source”:“pylint”, “惊人数字”:7, “startColumn”:14, “endLineNumber”:7, “结束列”:14 }你知道吗

the output I see is:
![the error][3]


  [1]: https://i.stack.imgur.com/bOSRm.png
  [2]: https://i.stack.imgur.com/Dkkqa.png
  [3]: https://i.stack.imgur.com/nyyfb.png

Tags: pyhttps模型comreturnobjectspngstack
1条回答
网友
1楼 · 发布于 2024-05-08 12:41:19

写:

werken = Werken.objects.all()

而不是:

werken = Werken.objects

然后: 使用安装pylint

pip install pylint-django

将此设置放在您的用户设置中:

{"python.linting.pylintArgs": [
     " load-plugins=pylint_django"
],}

相关问题 更多 >

    热门问题