sshwsfc / xadmin

Drop-in replacement of Django admin comes with lots of goodies, fully extensible with plugin support, pretty UI based on Twitter Bootstrap.
http://www.xadmin.io
BSD 3-Clause "New" or "Revised" License
4.76k stars 1.41k forks source link

xadmin+django2.0删除用户报错,get_deleted_objects() takes 3 positional arguments but 5 were given #622

Open flyingdown opened 6 years ago

flyingdown commented 6 years ago

get_deleted_objects这个方法,在1.x时确实是5个参数,2.0改了,删除数据就报错。

wsjsfcfc commented 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

developer-weize commented 6 years ago

怎么解决阿

hongweipeng commented 6 years ago

django2.x 版本的可以试试 django2 这个分支哦~

Lynhoo commented 6 years ago

试了django2 分支 还是没有解决这个问题

Lynhoo commented 6 years ago

找到问题了 我用的是 django2.0.5 get_deleted_objects() 还是需要5个参数,手动改一下就好了

finaluser commented 6 years ago

最新版的Django已经解决此问题