'str' object is not callable
来源:5-2 django的view实现商品列表页
石榴爸爸是好爸爸
2019-06-27
我按照老师的课程,自己编辑了简单的viewset,但是我发现,如果继承(mixins.ListModelMixin,viewsets.GenericViewSet) 则可以正常获取数据,但是
(mixins.CreateModelMixin,mixins.ListModelMixin,viewsets.GenericViewSet) 就会报’str’ object is not callable
我查了很多资料,还是不明白为何,我DRF是最新版本,我看是支持当前django的版本的
viewset类:
class GoodsFavViewSet(mixins.CreateModelMixin,mixins.ListModelMixin,viewsets.GenericViewSet):
""“
商品收藏ViewSet
”""
queryset = GoodsFav.objects.all()
serializer_class = GoodsFavSerializer
以下是报错信息!
////////////////////////
TypeError at /goodsfavs/
'str' object is not callable
Request Method:
GET
Request URL:
http://127.0.0.1:8000/goodsfavs/
Django Version:
2.0.3
Exception Type:
TypeError
Exception Value:
'str' object is not callable
Exception Location:
C:\Users\Administrator\Envs\qingdraw3.0_project\lib\site-packages\rest_framework\relations.py in display_value, line 228
Python Executable:
C:\Users\Administrator\Envs\qingdraw3.0_project\Scripts\python.exe
Python Version:
3.7.3
Python Path:
['C:\\Users\\Administrator\\PycharmProjects\\MxShop\\extra_apps',
'C:\\Users\\Administrator\\PycharmProjects\\MxShop\\apps',
'C:\\Users\\Administrator\\PycharmProjects\\MxShop',
'C:\\Users\\Administrator\\PycharmProjects\\MxShop',
'C:\\Users\\Administrator\\PycharmProjects\\MxShop',
'C:\\Users\\Administrator\\PycharmProjects\\MxShop\\apps',
'C:\\Users\\Administrator\\PycharmProjects\\MxShop\\extra_apps',
'D:\\Program Files\\JetBrains\\PyCharm 2019.1.3\\helpers\\pycharm_display',
'C:\\Users\\Administrator\\Envs\\qingdraw3.0_project\\Scripts\\python37.zip',
'C:\\Users\\Administrator\\Envs\\qingdraw3.0_project\\DLLs',
'C:\\Users\\Administrator\\Envs\\qingdraw3.0_project\\lib',
'C:\\Users\\Administrator\\Envs\\qingdraw3.0_project\\Scripts',
'c:\\users\\administrator\\appdata\\local\\programs\\python\\python37\\Lib',
'c:\\users\\administrator\\appdata\\local\\programs\\python\\python37\\DLLs',
'C:\\Users\\Administrator\\Envs\\qingdraw3.0_project',
'C:\\Users\\Administrator\\Envs\\qingdraw3.0_project\\lib\\site-packages',
'D:\\Program Files\\JetBrains\\PyCharm '
'2019.1.3\\helpers\\pycharm_matplotlib_backend',
'C:\\Users\\Administrator\\Envs\\qingdraw3.0_project\\lib\\site-packages\\odf',
'C:\\Users\\Administrator\\Envs\\qingdraw3.0_project\\lib\\site-packages\\odf',
'C:\\Users\\Administrator\\Envs\\qingdraw3.0_project\\lib\\site-packages\\odf',
'C:\\Users\\Administrator\\Envs\\qingdraw3.0_project\\lib\\site-packages\\odf',
'C:\\Users\\Administrator\\Envs\\qingdraw3.0_project\\lib\\site-packages\\odf',
'C:\\Users\\Administrator\\Envs\\qingdraw3.0_project\\lib\\site-packages\\odf',
'C:\\Users\\Administrator\\Envs\\qingdraw3.0_project\\lib\\site-packages\\odf']
写回答
2回答
-
石榴爸爸是好爸爸
提问者
2019-07-03
我Qq:6120088
00 -
bobby
2019-07-01
你留下qq 我加你看看,或者你把错误信息完整截图我看看,你这里的关键信息没有截图到
022019-07-06
Python前后端分离开发Vue+Django REST framework实战
Django REST framework课程视频,RESTFul API前后端分离开发
2873 学习 · 2457 问题
相似问题