蓝色的天_90  
python manage.py makemigrations projectmanage
Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "D:\Program Files\Python3.6\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "D:\Program Files\Python3.6\lib\site-packages\django\core\management\__init__.py", line 377, in execute
    django.setup()
  File "D:\Program Files\Python3.6\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\Program Files\Python3.6\lib\site-packages\django\apps\registry.py", line 114, in populate
    app_config.import_models()
  File "D:\Program Files\Python3.6\lib\site-packages\django\apps\config.py", line 211, in import_models
    self.models_module = import_module(models_module_name)
  File "D:\Program Files\Python3.6\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "E:\WF_Work\HappyAutoTest\projectmanage\models.py", line 10, in <module>
    from rest_framework.authtoken.models import Token
  File "D:\Program Files\Python3.6\lib\site-packages\rest_framework\authtoken\models.py", line 6, in <module>
    from django.utils.encoding import python_2_unicode_compatible
ImportError: cannot import name 'python_2_unicode_compatible'

解决方案:

#请使用

from six import python_2_unicode_compatible

#替代
from django.utils.encoding import python_2_unicode_compatible

 

 

 再次执行不报错

python manage.py makemigrations projectmanage
System check identified some issues:
Migrations for 'projectmanage':
  projectmanage\migrations\0001_initial.py
    - Create model Project

 

posted on 2020-04-29 15:43  蓝色的天_90  阅读(3303)  评论(0编辑  收藏  举报