python manage.py makemigrationsを成功させたい
djangoでファイルの変更をDBに入れるためにmigrationを作りたいのですが、
python manage.py makemigrations
で次のエラーメッセージが表示されました
また、python manage.py runserverと入力しても、動きませんでした
解決方法をご教授いただけると幸いです。
発生している問題・エラーメッセージ
『python manage.py makemigrationsの実行』 python manage.py makemigrations Traceback (most recent call last): File "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/core/management/base.py", line 328, in run_from_argv self.execute(*args, **cmd_options) File "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/core/management/base.py", line 366, in execute self.check() File "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/core/management/base.py", line 392, in check all_issues = self._run_checks( File "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/core/management/base.py", line 382, in _run_checks return checks.run_checks(**kwargs) File "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/core/checks/registry.py", line 72, in run_checks new_errors = check(app_configs=app_configs) File "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/core/checks/urls.py", line 35, in check_url_namespaces_unique if not getattr(settings, 'ROOT_URLCONF', None): File "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/conf/__init__.py", line 76, in __getattr__ self._setup(name) File "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/conf/__init__.py", line 63, in _setup self._wrapped = Settings(settings_module) File "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/conf/__init__.py", line 142, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/Users/roskiry000/.pyenv/versions/3.8.3/lib/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 'django_girl' During handling of the above exception, another exception occurred: 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 "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/core/management/base.py", line 341, in run_from_argv connections.close_all() File "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/db/utils.py", line 225, in close_all for alias in self: File "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/db/utils.py", line 219, in __iter__ return iter(self.databases) File "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/db/utils.py", line 153, in databases self._databases = settings.DATABASES File "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/conf/__init__.py", line 76, in __getattr__ self._setup(name) File "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/conf/__init__.py", line 63, in _setup self._wrapped = Settings(settings_module) File "/Users/roskiry000/.pyenv/versions/django_env/lib/python3.8/site-packages/django/conf/__init__.py", line 142, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/Users/roskiry000/.pyenv/versions/3.8.3/lib/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 'django_girl'
該当のソースコード
└── django_girl └── django_girl ├── config\ . │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-38.pyc │ │ ├── settings.cpython-38.pyc │ │ ├── urls.cpython-38.pyc │ │ └── wsgi.cpython-38.pyc │ ├── asgi.py │ ├── blog │ │ ├── __init__.py │ │ ├── admin.py │ │ ├── apps.py │ │ ├── migrations │ │ │ └── __init__.py │ │ ├── models.py │ │ ├── tests.py │ │ └── views.py │ ├── db.sqlite3 │ ├── manage.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py └── static 7 directories, 18 files 『以下pythonファイルです』(models.pyとsettings.pyのみ) [models.py] from django.db import models from django.conf import settings from django.utils import timezone # Create your models here. class Post(models.Model): author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) title = models.CharField(max_length=200) text = models.TextField() created_date = models.DateTimeField(default=timezone.now) published_date = models.DateTimeField(blank=True, null=True) def publish(self) self.published_date = timezone.now() self.save() def __str__(self): return self.title [settings.py]試したことに関連があるものだけを載せています # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'blog.apps.BlogConfig', ]
試したこと
・settings.pyとmodels.pyに誤字がないことを確認
・パスの問題なのではないかと考え、db.sqlite3をデフォルトからconfig .内へ移動
・パスの問題なのではないかと考え、カレントディレクトリをconfig .から、一つ前のdjango_girlに移動した
・settings.pyのINSTALLED_APPSの'blog.apps.BlogConfig',を 'blog.apps.BlogConfig .',に変更
・no module named 'django_girl'と書いてあったので、ダメもとで
pip show django_girlモジュールがないことを確認して、
pip install django_girlとやって、失敗
補足情報(FW/ツールのバージョンなど)
python 3.8.3です。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。