0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【動かして学ぶ! Python Django開発入門 第2版】python manage.py startapp accountsがNo Module nameになる

Posted at

起きたこと

「Chapter10 Djangoに認証機能を追加する」を進めていたときに本に沿って以下を実行したところエラーが表示された。

ターミナル
python manage.py startapp accounts

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "python3.8/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "python3.8/site-packages/django/core/management/__init__.py", line 420, in execute
    django.setup()
  File "python3.8/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "python3.8/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "python3.8/site-packages/django/apps/config.py", line 178, in create
    mod = import_module(mod_path)
  File "python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked

ModuleNotFoundError: No module named 'accounts'

原因

上記コマンド実行の前にリスト10.1のコード入力をしてしまっていたのが原因。

どうやらstartapp hogehogeする前にsetting.pyやsetting_commonn.pyに追加するアプリを入力してしまうとエラーを吐き出してしまう様子。

対策

本の順番に進める

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?