Django问题及解决

  • linux进入已安装好的数据库
    mysql -uroot -p
    

xadmin版本问题

  • django cannot import name 'python_2_unicode_compatible' from 'django.utils.encoding

    from django.utils.encoding import python_2_unicode_compatible
    

    替换成

    from six import python_2_unicode_compatible
    
  • django cannot import name 'six' from 'django.utils'
    进入文件夹python3.6/site-packages
    将six.py 复制到 django/utils

  • ImportError: cannot import name 'ugettext_lazy' from 'django.utils.translation'
    改为

    from django.utils.translation import gettext_lazy as _
    
  • ImportError: cannot import name 'smart_text' from 'django.utils.encoding'

    pip install django-admin-charts --upgrade
    pip install graphene-django --upgrade
    pip install django-elasticsearch-dsl --upgrade
    

    如果不管用
    改为

    from django.utils.encoding import smart_str
    
  •  from django.utils.http import urlencode, urlquote
     ImportError: cannot import name 'urlquote' from 'django.utils.http'
    

    改为

    from django.utils.http import urlencode, quote
    

    http.py文件

    from urllib.parse import (
    	ParseResult,
    	SplitResult,
    	_coerce_args,
    	_splitnetloc,
    	_splitparams,
    	scheme_chars,
    	quote,  #增加
    )
    
  • ImportError: cannot import name ‘FieldDoesNotExist’ from ‘django.db.models.fields’

    pip install django-advanced-filters

    from django.core.exceptions import FieldDoesNotExist
    

你可能感兴趣的:(django,django,python,后端)