makemigrations message

来源:3-3 django orm介绍与model设计

一一倾

2017-07-21

Failed to get real commands on module "djangostart": python process died with code 1: Traceback (most recent call last):

  File "C:\PyCharm 2017.1.5\helpers\pycharm\_jb_manage_tasks_provider.py", line 25, in <module>

    django.setup()

  File "C:\Users\Administrator\Envs\testvir2\lib\site-packages\django\__init__.py", line 18, in setup

    apps.populate(settings.INSTALLED_APPS)

  File "C:\Users\Administrator\Envs\testvir2\lib\site-packages\django\apps\registry.py", line 85, in populate

    app_config = AppConfig.create(entry)

  File "C:\Users\Administrator\Envs\testvir2\lib\site-packages\django\apps\config.py", line 90, in create

    module = import_module(entry)

  File "c:\python27\Lib\importlib\__init__.py", line 37, in import_module

    __import__(name)

ImportError: No module named message


之后,我在settings中添加了,sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
sys.path.insert(0, os.path.join(BASE_DIR, 'extra_apps')),如下:

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
sys.path.insert(0, os.path.join(BASE_DIR, 'extra_apps'))

运行出现错误如下:

Failed to get real commands on module "djangostart": python process died with code 1: Traceback (most recent call last):

  File "C:\PyCharm 2017.1.5\helpers\pycharm\_jb_manage_tasks_provider.py", line 25, in <module>

    django.setup()

  File "C:\Users\Administrator\Envs\testvir2\lib\site-packages\django\__init__.py", line 17, in setup

    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)

  File "C:\Users\Administrator\Envs\testvir2\lib\site-packages\django\conf\__init__.py", line 55, in __getattr__

    self._setup(name)

  File "C:\Users\Administrator\Envs\testvir2\lib\site-packages\django\conf\__init__.py", line 43, in _setup

    self._wrapped = Settings(settings_module)

  File "C:\Users\Administrator\Envs\testvir2\lib\site-packages\django\conf\__init__.py", line 99, in __init__

    mod = importlib.import_module(self.SETTINGS_MODULE)

  File "c:\python27\Lib\importlib\__init__.py", line 37, in import_module

    __import__(name)

  File "C:\Users\Administrator\PycharmProjects\djangostart\djangostart\settings.py", line 17, in <module>

    sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))

NameError: name 'sys' is not defined

请问是什么原因?

写回答

1回答

一一倾

提问者

2017-07-21

已解决,要import sys

0
1
bobby
好的,
2017-07-24
共1条回复

Python3.6+django+xadmin,打造在线教育平台

【毕设】Python 2.7到3.6 完美适配,Django升级2.0

3677 学习 · 4038 问题

查看课程