导入错误:没有名为 app_name 的模块



我是python的新手,我在SO上看到了类似的问题,但无法弄清楚我的Django应用程序出了什么问题。

settings.py,我以虚线模块形式添加了我的应用程序:

INSTALLED_APPS = (
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'mproject.blog',
)

和回溯:

D:py promproject>python manage.py runserver 9999
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
  execute_from_command_line(sys.argv)
  File "C:Python27libsite-packagesdjangocoremanagement__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "C:Python27libsite-packagesdjangocoremanagement__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:Python27libsite-packagesdjangocoremanagementbase.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "C:Python27libsite-packagesdjangocoremanagementbase.py", line 280, in execute
    translation.activate('en-us')
  File "C:Python27libsite-packagesdjangoutilstranslation__init__.py", line 130, in activate
    return _trans.activate(language)
  File "C:Python27libsite-packagesdjangoutilstranslationtrans_real.py", line 188, in activate
    _active.value = translation(language)
  File "C:Python27libsite-packagesdjangoutilstranslationtrans_real.py", line 177, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "C:Python27libsite-packagesdjangoutilstranslationtrans_real.py", line 159, in _fetch
    app = import_module(appname)
  File "C:Python27libsite-packagesdjangoutilsimportlib.py", line 40, in import_module
    __import__(name)
ImportError: No module named blog

manage.py我有

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mproject.settings")

如何解决这个问题?

我认为你不需要使用myproject.blog.

只需将blog添加到已安装的应用程序。这就足够了。

相关内容

  • 没有找到相关文章

最新更新