zoukankan      html  css  js  c++  java
  • Django2.0 应用 Xadmin 报错解决(转载)

    原文地址:https://blog.csdn.net/GoAheadNeverTurnBack/article/details/8143362

    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

  • 相关阅读:
    Nginx专题(二)-----虚拟主机、location规则、rewrite、负载均衡配置
    Nginx专题(一)-----简介
    springMVC自动转义问题
    Tomcat专题(三)-----Tomcat性能优化
    Tomcat专题(二)-----Tomcat源码、嵌入式Tomcat
    Tomcat专题(一)-----架构体系
    jvm性能调优(五)-----深入了解性能优化
    jvm性能调优(四)-----编写高效的java代码
    jvm性能调优(三)-----JVM的执行子系统
    jvm性能调优(二)-----垃圾回收、内存分配
  • 原文地址:https://www.cnblogs.com/shuaimeng/p/11168082.html
Copyright © 2011-2022 走看看