Open flyingdown opened 6 years ago
@flyingdown 今天也碰到类似错误缺少参数admin_site, using(django2.0.6),翻了下git上的源码
django2.0.*是这样(https://github.com/django/django/blob/stable/2.0.x/django/contrib/admin/utils.py)
def get_deleted_objects(objs, opts, user, admin_site, using):
django2.1.*是这样(https://github.com/django/django/blob/stable/2.1.x/django/contrib/admin/utils.py)
def get_deleted_objects(objs, request, admin_site):
然后xadmin2.0.1里面是这样的
if django_version > (2, 0):
deletable_objects, model_count, perms_needed, protected = get_deleted_objects(
queryset, self.opts, self.admin_site)
else:
deletable_objects, model_count, perms_needed, protected = get_deleted_objects(
queryset, self.opts, self.user, self.admin_site, using)
但是这样还是没有办法处理, 原因就是上面说的2.0.和2.1.不一样,如果能根据参数个数执行代码的话会比判断版本好一点,比如 get_deleted_objects.code.co_argcount == 3
怎么解决阿
django2.x 版本的可以试试 django2
这个分支哦~
试了django2 分支 还是没有解决这个问题
找到问题了 我用的是 django2.0.5 get_deleted_objects() 还是需要5个参数,手动改一下就好了
最新版的Django已经解决此问题
get_deleted_objects这个方法,在1.x时确实是5个参数,2.0改了,删除数据就报错。