Django2.0 应用 Xadmin 报错解决(补充)

3 篇文章 0 订阅
2 篇文章 0 订阅

 

今天继续研究Django 发现又有了新情况!解决方法奉上!

 

1、TypeError at /xadmin/

 

login() got an unexpected keyword argument 'current_app'错误
Exception Location: /home/wuchao/PycharmProjects/mxonline3/extra_apps/xadmin/views/website.py in get, line 66



解决方案:根据提示进入website,注释61行
         

 #'current_app': self.admin_site.name,

 

2、AttributeError at /xadmin/

 

'Media' object has no attribute 'add_css'
Request Method:GET
Request URL:http://localhost:8000/xadmin/
Django Version:2.0.1
Exception Type:AttributeError
Exception Value:
'Media' object has no attribute 'add_css'
Exception Location:/home/wuchao/PycharmProjects/mxonline3/extra_apps/xadmin/util.py in vendor, line 94

解决方案:
将util.py 中的86行 def vendor(*tags):方法体改为:

css = {'screen': []}
js = []
for tag in tags:
    file_type = tag.split('.')[-1]
    files = xstatic(tag)
    if file_type == 'js':
        js.extend(files)
    elif file_type == 'css':
        css['screen'] += files
return Media(css=css, js=js)

 

3、AttributeError at /xadmin/xadmin/log/

 

'DateTimeField' object has no attribute 'rel'
Request Method:GET
Request URL:http://localhost:8000/xadmin/xadmin/log/
Django Version:2.0.1
Exception Type:AttributeError
Exception Value:
'DateTimeField' object has no attribute 'rel'
Exception Location:/home/wuchao/PycharmProjects/mxonline3/extra_apps/xadmin/views/list.py in get_list_queryset, line 228

 

修改 views/list.py 中228行

if isinstance(field.rel, models.ManyToOneRel):
    related_fields.append(field_name)

 修改为

if isinstance(field.remote_field, models.ManyToOneRel):
    related_fields.append(field_name)

后面继续报这个“rel”的错误,解决方法参考3,根据 Exception Location 提示 找到Xadmin报错行,将 field.rel 修改为 field.remote_field

 

  • 3
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值