前提・実現したいこと
動かして学ぶ!python Django開発入門の手順通りにプログラムを作っており、P135に書かれているようにpython manage.py runserverを用い開発サーバーを起動したい
###ソースコード(追記のsettings.py)
python
1import os 2from pathlib import Path 3 4BASE_DIR = Path(__file__).resolve().parent.parent 5 6SECRET_KEY = 'q6y8^q5+dpgyuk4^jb9^x(f9s#9n$v1hq)zhom$41lhwd7)hhn' 7 8DEBUG = True 9 10ALLOWED_HOSTS = [] 11 12INSTALLED_APPS = [ 13 'django.contrib.admin', 14 'django.contrib.auth', 15 'django.contrib.contenttypes', 16 'django.contrib.sessions', 17 'django.contrib.messages', 18 'django.contrib.staticfiles', 19 20 'diary.apps.DiaryConfig' 21] 22 23MIDDLEWARE = [ 24 'django.middleware.security.SecurityMiddleware', 25 'django.contrib.sessions.middleware.SessionMiddleware', 26 'django.middleware.common.CommonMiddleware', 27 'django.middleware.csrf.CsrfViewMiddleware', 28 'django.contrib.auth.middleware.AuthenticationMiddleware', 29 'django.contrib.messages.middleware.MessageMiddleware', 30 'django.middleware.clickjacking.XFrameOptionsMiddleware', 31] 32 33ROOT_URLCONF = 'private_diary.urls' 34 35TEMPLATES = [ 36 { 37 'BACKEND': 'django.template.backends.django.DjangoTemplates', 38 'DIRS': [], 39 'APP_DIRS': True, 40 'OPTIONS': { 41 'context_processors': [ 42 'django.template.context_processors.debug', 43 'django.template.context_processors.request', 44 'django.contrib.auth.context_processors.auth', 45 'django.contrib.messages.context_processors.messages', 46 ], 47 }, 48 }, 49] 50 51WSGI_APPLICATION = 'private_diary.wsgi.application' 52 53 54DATABASES = { 55 'default': { 56 'ENGINE': 'django.db.backends.postgresql_psycopg2', 57 'NAME': 'private_diary', 58 'USER': os.environ.get('DB_USER'), 59 'PASSWORD': os.environ.get('DB_PASSWORD'), 60 'HOST': '', 61 'PORT': '', 62 } 63} 64 65AUTH_PASSWORD_VALIDATORS = [ 66 { 67 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 68 }, 69 { 70 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 71 }, 72 { 73 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 74 }, 75 { 76 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 77 }, 78] 79 80LANGUAGE_CODE = 'ja' 81 82TIME_ZONE = 'Asia/Tokyo' 83 84USE_I18N = True 85 86USE_L10N = True 87 88USE_TZ = True 89 90STATIC_URL = '/static/' 91 92LOGGING = { 93 'version': 1, 94 'disable_existing_loggers': False, 95 96 'loggers': { 97 'django': { 98 'handlers': ['console'], 99 'level': 'INFO', 100 }, 101 'diary': { 102 'handlers': ['console'], 103 'level': 'INFO', 104 }, 105 }, 106 'handlers': { 107 'console': { 108 'level': 'DEBUG', 109 'class': 'logging.StreamHandler', 110 'formatter': 'dev' 111 }, 112 }, 113 114 'formatter': { 115 'dev': { 116 'format': '\t'.join([ 117 '%(asctime)s', 118 '[%(levelname)s]', 119 '%(pathname)s(Line:%(lineno)d)', 120 '%(massage)s' 121 ]) 122 }, 123 } 124} 125
試したこと
エラーが多すぎて、わからないのですが
C:\Users\rikuw\AppData\Local\Programs\Python\Python38\lib\とどのエラーの文に書いているので別のpython.exeを参照してしまっているのかと考えていますが解決法が全く分かりません。
補足情報(FW/ツールのバージョンなど)
C:\Users\rikuw\venv_private_diary\private_diaryのmanage.pyをrunserserしました。
(venv_private_diary)C:\Users\rikuw\venv_private_diary\private_diary>py --version
Python 3.8.5
(venv_private_diary)C:\Users\rikuw\venv_private_diary\private_diary>python -m django --version
3.1.1
###追記(スペルミスを直した後のエラーメッセージ)
2020-09-04 16:41:31,030 [INFO] C:\Users\rikuw\venv_private_diary\lib\site-packages\django\utils\autoreload.py(Line:612) Watching for file changes with StatReloader System check identified no issues (0 silenced). Exception in thread django-main-thread: Traceback (most recent call last): File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection self.connect() File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\db\backends\base\base.py", line 200, in connect self.connection = self.get_new_connection(conn_params) File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\db\backends\postgresql\base.py", line 187, in get_new_connection connection = Database.connect(**conn_params) File "C:\Users\rikuw\venv_private_diary\lib\site-packages\psycopg2\__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\rikuw\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner self.run() File "C:\Users\rikuw\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper fn(*args, **kwargs) File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\core\management\commands\runserver.py", line 121, in inner_run self.check_migrations() File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\core\management\base.py", line 459, in check_migrations executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__ self.loader = MigrationLoader(self.connection) File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\db\migrations\loader.py", line 53, in __init__ self.build_graph() File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\db\migrations\loader.py", line 216, in build_graph self.applied_migrations = recorder.applied_migrations() File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\db\migrations\recorder.py", line 77, in applied_migrations if self.has_table(): File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\db\migrations\recorder.py", line 55, in has_table with self.connection.cursor() as cursor: File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\db\backends\base\base.py", line 259, in cursor return self._cursor() File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\db\backends\base\base.py", line 235, in _cursor self.ensure_connection() File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection self.connect() File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\db\utils.py", line 90, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection self.connect() File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\db\backends\base\base.py", line 200, in connect self.connection = self.get_new_connection(conn_params) File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "C:\Users\rikuw\venv_private_diary\lib\site-packages\django\db\backends\postgresql\base.py", line 187, in get_new_connection connection = Database.connect(**conn_params) File "C:\Users\rikuw\venv_private_diary\lib\site-packages\psycopg2\__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) django.db.utils.OperationalError