django2.0集成xadmin0.6报错集锦
1、django2.0把from django.core.urlresolvers修改成了django.urls
报错如下:
1
2
3
|
File "D:\Envs\django-xadmin\lib\site-packages\xadmin-0.6.1-py3.6.egg\xadmin\models.py", line 8, in <module> from django.core.urlresolvers import NoReverseMatch, reverse ModuleNotFoundError: No module named 'django.core.urlresolvers' |
解决方法:
修改D:\Envs\django-xadmin\lib\site-packages\xadmin-0.6.1-py3.6.egg\xadmin\models.py 文件
把from django.core.urlresolvers import NoReverseMatch, reverse 修改为:
1
|
from django.urls import NoReverseMatch, reverse |
2、django2.0中需要给外键ForeignKey指定on_delete参数
报错如下:
1
2
3
4
5
|
File "D:\Envs\django-xadmin\lib\site-packages\xadmin-0.6.1-py3.6.egg\xadmin\models.py", line 45, in <module> class Bookmark(models.Model): File "D:\Envs\django-xadmin\lib\site-packages\xadmin-0.6.1-py3.6.egg\xadmin\models.py", line 49, in Bookmark content_type = models.ForeignKey(ContentType) TypeError: __init__() missing 1 required positional argument: 'on_delete' |
解决方法:
把content_type = models.ForeignKey(ContentType)修改为:
1
|
content_type = models.ForeignKey(ContentType,on_delete=models.CASCADE) |
3、 django2.0 forms表单初始化只需要一个参数
报错如下:
1
2
3
4
|
model = ModelChoiceField(label=_(u'Target Model'), widget=exwidgets.AdminSelectWidget) File "D:\Envs\django-xadmin\lib\site-packages\xadmin-0.6.1-py3.6.egg\xadmin\views\dashboard.py", line 284, in __init__ forms.Field.__init__(self, required, widget, label, initial, help_text, *args, **kwargs) TypeError: __init__() takes 1 positional argument but 6 were given |
解决方法:
把forms.Field.__init__(self, required, widget, label, initial, help_text, *args, **kwargs) 修改成:
1
|
forms.Field.__init__(self) |
4、 导入QUERY_TERMS报错
报错如下:
1
2
3
|
File "D:\Envs\django-xadmin\lib\site-packages\xadmin-0.6.1-py3.6.egg\xadmin\plugins\filters.py", line 10, in <module> from django.db.models.sql.query import LOOKUP_SEP, QUERY_TERMS ImportError: cannot import name 'QUERY_TERMS' |
解决方法:
把
from django.db.models.sql.query import LOOKUP_SEP, QUERY_TERMS
修改为:
1
2
|
from django.db.models.sql.query import LOOKUP_SEP from django.db.models.sql.constants import QUERY_TERMS |
5、Settings缺少MIDDLEWARE_CLASSES属性,django2.0把MIDDLEWARE_ClASSES改成MIDDLEWARE
报错如下:
1
2
3
4
5
|
File "D:\Envs\django-xadmin\lib\site-packages\xadmin-0.6.1-py3.6.egg\xadmin\plugins\language.py", line 24, in <module> if settings.LANGUAGES and 'django.middleware.locale.LocaleMiddleware' in settings.MIDDLEWARE_CLASSES: File "D:\Envs\django-xadmin\lib\site-packages\django\conf\__init__.py", line 57, in __getattr__ val = getattr(self._wrapped, name) AttributeError: 'Settings' object has no attribute 'MIDDLEWARE_CLASSES' |
把
if settings.LANGUAGES and 'django.middleware.locale.LocaleMiddleware' in settings.MIDDLEWARE_ClASSES:
修改为:
1
|
if settings.LANGUAGES and 'django.middleware.locale.LocaleMiddleware' in settings.MIDDLEWARE: |
6、 django-formtools导入失败,需要更新django-formtools
报错如下:
1
2
3
|
File "C:\Users\laoyan\Desktop\xadmin-django2\xadmin-django2\demo_app\..\xadmin\plugins\wizard.py", line 12, in <module> from django.contrib.formtools.wizard.storage import get_storage ModuleNotFoundError: No module named 'django.contrib.formtools' |
卸载django-formtools
pip uninstall django-formtools
重新安装新版本的django-formtools
1
|
pip install django-formtools==2.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 结果方案:屏蔽61
#'current_app': self.admin_site.name,
AttributeError at /xadmin/
'Media' object has no attribute 'add_css'
'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)
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 中228H行
if isinstance(field.rel, models.ManyToOneRel):
related_fields.append(field_name)
修改为
if isinstance(field.remote_field, models.ManyToOneRel):
related_fields.append(field_name)
相关推荐
python3.6环境中django2.0与xadmin0.6结合打造强悍的后台管理页面(一)
django2.0集成xadmin0.6报错集锦的更多相关文章
- python3.6 + django2.0.6 + xadmin0.6
django2.0集成xadmin0.6报错集锦 http://www.lybbn.cn/data/bbsdatas.php?lybbs=50 1.django2.0把from django.core ...
- react+typescript报错集锦<持续更新>
typescript报错集锦 错误:Import sources within a group must be alphabetized.tslint(ordered-imports) 原因:impo ...
- SpringBoot- springboot集成Redis出现报错:No qualifying bean of type 'org.springframework.data.redis.connection.RedisConnectionFactory'
Springboot将accessToke写入Redisk 缓存,springboot集成Redis出现报错 No qualifying bean of type 'org.springframewo ...
- jmeter4.0 执行jmeter_server.bat报错
Jmeter分布式执行1.-------------------------------Jmeter4.0 执行jmeter_server.bat 报错,是由于4.0要手工生成密钥 bin目录下 ...
- mysql-connector-java升级到6.0以后启动tomcat报错
mysql-connector-java升级到6.0以后启动tomcat报错 java.sql.SQLException: The server time zone value '�й���ʱ��' ...
- DRF接入Oauth2.0认证[微博登录]报错21322重定向地址不匹配
DRF接入Oauth2.0认证[微博登录]报错21322重定向地址不匹配 主题自带了微博登陆接口,很简单的去新浪微博开放平台创建了网页应用,然后把APP ID和 AppSecret填好后,以为大功告成 ...
- ojdbc15-10.2.0.4.0.jar maven 引用报错 Dependency 'com.oracle:ojdbc15:10.2.0.4.0' not found
ojdbc15-10.2.0.4.0.jar maven 引用报错 问题现象 在 Maven 工程中引用 ojdbc15-10.2.0.4.0.jar 报错,报错信息:Dependency 'com. ...
- Linux安装Redis 6.0.5 ./install_server.sh报错
Linux安装Redis 6.0.5 ./install_server.sh报错 linux 安装Redis6.0.5时 进行到./install_server.sh时报错, This systems ...
- 8.4 sikuli 集成进eclipse 报错:Unsupported major.minor version 51.0
8.3中的问题Win32Util.dll: Can't load 32-bit .dll on a AMD 64 bit platform 解决之后,执行还是会有报错:Unsupported maj ...
随机推荐
- c++ list reverse_iterator
#pragma warning(disable:4786) #include <set> #include <iostream> using namespace std ; t ...
- struts2 + spring3 + mybatis3 环境搭建
struts2 + spring3 + mybatis3 1. 框架下载 struts2: http://struts.apache.org/ 下载 struts-2.3.14-all.zip spr ...
- 图像的降采样与升采样(二维插值)----转自LOFTER-gengjiwen
图像的降采样与升采样(二维插值) 1.先说说这两个词的概念: 降采样,即是采样点数减少.对于一幅N*M的图像来说,如果降采样系数为k,则即是在原图中 每行每列每隔k个点取一个点组成一幅图像.降采样很容 ...
- shell中判断一个变量是否为0或者为某个具体的值
需求说明: 在实际写脚本的过程中,需要判断某个变量的值是否为某个数字, 比如,判断某个进程的数量是否为0用来确定进程是否存在,这样的情况. 简单来说,算术比较. 测试过程: 通过以下的脚本来判断mys ...
- 2.1 C语言下的位运算
位运算符: 注:运算量仅仅能为整型和字符型数据,不能是实数型的数据. 当进行&运算时:0&1=0.1&0=0:1&1=1:0&0=0: 当进行|运算时:0|1= ...
- JavaScript------生成Guid方法
转载: http://blog.csdn.net/limm33/article/details/51536529 代码: function newGuid() { var guid = "& ...
- Java精选笔记_其他IO流(ObjectInputStream、DataInputStream、PrintStream、标准输入输出流)
其他IO流 ObjectInputStream和ObjectOutputStream 如果希望永久将对象转为字节数据写入到硬盘上,即对象序列化,可以使用ObjectOutputStream(对象输出流 ...
- Java 基本语法----进制、运算符
进 制 对于整数,有四种表示方式: 二进制:0,1 ,满 2 进 1.以 0b 或 0B 开头.十进制:0-9 ,满 10 进 1. 八进制:0-7 ,满 8 进1. 以数字 0 开头表示.十六进制: ...
- ios button标记
在写项目的时候,for循环创建多个button,在需要设置背景图片和,需要标记所选中的button的需求, 在这里提供两种方法: 一: 1:把for循环创建的button全部装到一个新建的数组中,把他 ...
- python2.0_day22_web聊天室二
上节内容已经实现了客户端使用长轮询的方式获取消息的功能.但是还没有展现到前端.本节内容将实现1.展现消息到前端窗口.2.客户端之间发送图片和文件.3.文件上传时显示进度条 下面我们来实现上面3个功能. ...