我是靠谱客的博主 勤恳哈密瓜,这篇文章主要介绍AssertionError:` base_name` argument not specified...... a not have a` .queryset` attribute.,现在分享给大家,希望可以做个参考。
一转眼,erp系统又学了好些天了 哈哈哈哈
今天又遇到了个新问题 和大家一起分享一下!
问题描述
AssertionError: base_name argument not specified, and could not
automatically determine the name from the viewset, as it does not
have a .queryset attribute.
原因分析
这个问题是在重写分页的方法之后,在进行URL注册时所报的错。
在views
中去掉了queryset属性,改用get_queryset()
方法,此时basename这个值必须补充!!
解决方法
router注册URL时,补充basename即可。
另外一种解决方案是在重写get_queryset前设置好queryset的默认值
queryset = DeptModel.objects.all()
serializer_class = DeptSerializer
pagination_class = GlobalPagination
最后
以上就是勤恳哈密瓜最近收集整理的关于AssertionError:` base_name` argument not specified...... a not have a` .queryset` attribute.的全部内容,更多相关AssertionError:`内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复