django xadmin一些报错

Error:

1、File "/home/qwer/.local/lib/python3.6/site-packages/xadmin/sites.py", line 7, in <module>

             from django.utils import six

ImportError: cannot import name 'six'

解决:
找到traceback中最后一条目录,即????\python3.8\lib\site-packages\xadmin\sites.py”,将文件中的第7行的from django.utils import six 改成import six

Ref: https://blog.csdn.net/ASerendipity_/article/details/103710815

 

2、Python.framework/Versions/3.9/lib/python3.9/site-packages/MySQLdb/__init__.py", line 24, in <module>

  version_info, _mysql.version_info, _mysql.__file__

  NameError: name '_mysql' is not defined

此报错主要因为Mysqldb 不兼容 python3.5 以后的版本

 

解决:

打开 项目目录内的  __init__.py

添加上

import pymysql

pymysql.version_info = (1, 4, 13, "final", 0)

pymysql.install_as_MySQLdb()

ref: https://blog.csdn.net/m0_47970692/article/details/114106262

 

3、from django.utils.encoding import python_2_unicode_compatible, smart_text

ImportError: cannot import name 'python_2_unicode_compatible'

 

解决:

You can fix this by changing the import wherever you get this error,

 

old code: from django.utils.encoding import python_2_unicode_compatible, smart_text

Updated code:

from django.utils.encoding import smart_text

from six import python_2_unicode_compatible

 

Go to the mentioned path and edit it, or upgrade all libraries, it should solve the issue.

Ref:https://github.com/jazzband/django-auditlog/issues/231

 

4、from django.forms.forms import pretty_name

ImportError: cannot import name 'pretty_name'

 

解决:

You can fix this by changing the import wherever you get this error,

 

old code: from django.forms.forms import pretty_name

Updated code: from django.forms import forms

 

5、No module named 'django.contrib.staticfiles.templatetags'

 

解决:

将from django.contrib.staticfiles.templatetags.staticfiles import static

替换成:

from django.templatetags.static import static

ref:https://www.cnblogs.com/chushujin/p/12539952.html

 

6、from django.db.models.fields import FieldDoesNotExist

ImportError: cannot import name 'FieldDoesNotExist'

 

解决:

from django.db.models.fields import FieldDoesNotExist

改成

from django.core.exceptions import FieldDoesNotExist

 

参考:https://stackoverflow.com/questions/63300404/makemigration-error-on-django-importerror-cannot-import-name-fielddoesnotexi

 

 

7、from import_export.admin import DEFAULT_FORMATS, SKIP_ADMIN_LOG, TMP_STORAGE_CLASS

ImportError: cannot import name 'SKIP_ADMIN_LOG'

 

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值