Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
flyingdown opened this issue Aug 30, 2018 · 6 comments

Comments

@flyingdown
Copy link

flyingdown commented Aug 30, 2018

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

@wsjsfcfc
Copy link

wsjsfcfc commented Aug 31, 2018

@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
Copy link

怎么解决阿

@hongweipeng
Copy link

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

@Lynhoo
Copy link

Lynhoo commented Sep 28, 2018

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

@Lynhoo
Copy link

Lynhoo commented Sep 28, 2018

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

@finaluser
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants