错误1
# ImportError: cannot import name ‘six‘ # 解决方法 pip install six # 然后找到 Lib\site-packages 下的six.py 复制到 django/utils下面 # 问题解决
错误2
# ImportError: cannot import name ‘python_2_unicode_compatible‘ from django.utils.encoding import force_text, python_2_unicode_compatible # 改为 from django.utils.encoding import force_text from django.utils.six import python_2_unicode_compatible # 问题解决
错误3
# ModuleNotFoundError: No module named ‘django.contrib.staticfiles.templatetags‘ if ‘django.contrib.staticfiles‘ in settings.INSTALLED_APPS: from django.contrib.staticfiles.templatetags.staticfiles import static else: from django.templatetags.static import static # 改为 # if ‘django.contrib.staticfiles‘ in settings.INSTALLED_APPS: # from django.contrib.staticfiles.templatetags.staticfiles import static # else: from django.templatetags.static import static # 问题解决
错误4
# TypeError: render() got an unexpected keyword argument ‘renderer‘ # 跟随错误提示 return widget.render( name=self.html_initial_name if only_initial else self.html_name, value=self.value(), attrs=attrs, renderer=self.form.renderer, ) # 改为 return widget.render( name=self.html_initial_name if only_initial else self.html_name, value=self.value(), attrs=attrs, # renderer=self.form.renderer, ) # 问题解决
注意:
INSTALLED_APPS = [ ‘django.contrib.admin‘, ‘django.contrib.auth‘, ‘django.contrib.contenttypes‘, ‘django.contrib.sessions‘, ‘django.contrib.messages‘, ‘django.contrib.staticfiles‘, ‘xadmin‘, ‘crispy_forms‘, ‘corsheaders‘, ‘rest_framework‘, ‘home‘, ] # 在注册APP的时候 crispy_forms 要放在 xadmin下面否则会报错
原文:https://www.cnblogs.com/wtil/p/12363875.html