您的位置:首页 > 其它

解决使用drf-haystack报错ImportError: cannot import name get_count

2018-06-27 13:28 645 查看
版权声明:转载请注明出处 https://blog.csdn.net/fanlei5458/article/details/80827840

如果在配置完haystack并启动程序后,出现如下异常,是因为drf-haystack还没有适配最新版本的REST framework框架

可以通过修改

REST framework
框架代码,补充
_get_count
函数定义即可
文件路径 虚拟环境下的
lib/python3.6/site-packages/rest_framework/pagination.py

def _get_count(queryset):
"""
Determine an object count, supporting either querysets or regular lists.
"""
try:
return queryset.count()
except (AttributeError, TypeError):
return len(queryset)
阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: