ImportError: No module named message

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

宝慕林7112356

2018-03-07

运行makemigrations报错:

bash -cl "/Users/lyx/PycharmProjects/djangotest/venv/bin/python /Applications/PyCharm.app/Contents/helpers/pycharm/django_manage.py makemigrations /Users/lyx/PycharmProjects/djangotest"

Traceback (most recent call last):

  File "/Applications/PyCharm.app/Contents/helpers/pycharm/django_manage.py", line 43, in <module>

    run_module(manage_file, None, '__main__', True)

  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 176, in run_module

    fname, loader, pkg_name)

  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 82, in _run_module_code

    mod_name, mod_fname, mod_loader, pkg_name)

  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code

    exec code in run_globals

  File "/Users/lyx/PycharmProjects/djangotest/manage.py", line 22, in <module>

    execute_from_command_line(sys.argv)

  File "/Users/lyx/PycharmProjects/djangotest/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line

    utility.execute()

  File "/Users/lyx/PycharmProjects/djangotest/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute

    django.setup()

  File "/Users/lyx/PycharmProjects/djangotest/venv/lib/python2.7/site-packages/django/__init__.py", line 27, in setup

    apps.populate(settings.INSTALLED_APPS)

  File "/Users/lyx/PycharmProjects/djangotest/venv/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate

    app_config = AppConfig.create(entry)

  File "/Users/lyx/PycharmProjects/djangotest/venv/lib/python2.7/site-packages/django/apps/config.py", line 94, in create

    module = import_module(entry)

  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module

    __import__(name)

ImportError: No module named message


Process finished with exit code 1

已经添加过installed_app

写回答

2回答

SingleVergil

2018-04-01

我也出现了这个问题  

'message',   -----   >   ''apps.message',   就可以了  

不知道为什么关键是 这个注册有什么特殊写法和规矩吗?

1
0

宝慕林7112356

提问者

2018-03-07

把settings.py里面的INSTALLED_APPS修改成INSTALLED_APPS = [
   'django.contrib.admin',
   'django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   'apps.message',
]

urls.py修改成from apps.message.views import getform


然后可以正常运行,我看老师的视频里不需要这样的啊,我已经把apps make source root了,是不是settings里的BASE_DIR也要配置?

1
5
weibo_奥特斯东_0
按照你说的改了就成功了,谢谢
2018-08-16
共5条回复

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

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

3677 学习 · 4038 问题

查看课程