持续更新
报错1
ImportError: cannot import name 'six' from 'django.utils' (/usr/local/lib/python3.7/site-packages/django/utils/__init__.py)
# 解决办法:
pip install six
# 进入/python3.7/site-packages 复制six.py文件到/python3.7/site-packages/django/utils中
报错2
ImportError: cannot import name 'python_2_unicode_compatible' from 'django.utils.encoding'
# 解决办法:
# 进入 报错对应文件 修改第11行 如下图
from django.utils.encoding import python_2_unicode_compatible, smart_text
# 修改为
from django.utils.encoding import smart_text
from six import python_2_unicode_compatible
image.png
报错3
ImportError: cannot import name 'pretty_name' from 'django.forms.forms' (/usr/local/lib/python3.7/site-packages/django/forms/forms.py)
# 解决办法:
进入报错对应文件 注释第7行
# from django.forms.forms import pretty_name
报错4
ModuleNotFoundError: No module named 'django.contrib.staticfiles.templatetags'
# 解决办法:
# 进入报错对应文件 修改第24行
from django.contrib.staticfiles.templatetags.staticfiles import static
# 修改为
from django.templatetags.static import static
报错5
ImportError: cannot import name 'FieldDoesNotExist' from 'django.db.models.fields' (/usr/local/lib/python3.7/site-packages/django/db/models/fields/__init__.py)
# 解决办法:
# 进入报错对应文件 修改第9行
# from django.db.models.fields import FieldDoesNotExist
# 修改为
from django.core.exceptions import FieldDoesNotExist
# 如果导入部分内容是:
from django.db.models import FieldDoesNotExist, Avg, Max, Min, Count, Sum
# 则修改为:
from django.db.models import Avg, Max, Min, Count, Sum
from django.core.exceptions import FieldDoesNotExist
网友评论