[英]python manage.py runserver won't run after git cloning my repo
Please I am having issues running python manage.py runserver after git cloning my project repo, creating a virtual environment and installing all required requirements.在 git 克隆我的项目存储库、创建虚拟环境并安装所有必需的要求后,我在运行 python manage.py runserver 时遇到问题。 Please response is needed urgently
急需回复
(.venv) PS C:\Users\ASUS\desktop\project\file-comp-107> python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\db\backends\base\base.py", line 244, in ensure_connection
self.connect()
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\db\backends\base\base.py", line 225, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\db\backends\postgresql\base.py", line 203, in get_new_connection
connection = Database.connect(**conn_params)
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\psycopg2\__init__.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: fe_sendauth: no password supplied
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\threading.py", line 1009, in _bootstrap_inner
self.run()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\threading.py", line 946, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\core\management\commands\runserver.py", line 137, in inner_run
self.check_migrations()
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\core\management\base.py", line 576, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\db\migrations\loader.py", line 58, in __init__
self.build_graph()
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\db\migrations\loader.py", line 235, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\db\migrations\recorder.py", line 81, in applied_migrations
if self.has_table():
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\db\migrations\recorder.py", line 57, in has_table
with self.connection.cursor() as cursor:
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\db\backends\base\base.py", line 284, in cursor
return self._cursor()
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\db\backends\base\base.py", line 260, in _cursor
self.ensure_connection()
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\db\backends\base\base.py", line 243, in ensure_connection
with self.wrap_database_errors:
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\db\utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\db\backends\base\base.py", line 244, in ensure_connection
self.connect()
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\db\backends\base\base.py", line 225, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\django\db\backends\postgresql\base.py", line 203, in get_new_connection
connection = Database.connect(**conn_params)
File "C:\Users\ASUS\desktop\project\file-comp-107\.venv\lib\site-packages\psycopg2\__init__.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: connection to server at "localhost" (::1), port 5432 failed: fe_sendauth: no password supplied
As the error returned is django.db.utils.OperationalError: connection to server at "localhost" (::1), port 5432 failed: fe_sendauth: no password supplied
, I assume a environment variable which sets the DB password is missing.由于返回的错误是
django.db.utils.OperationalError: connection to server at "localhost" (::1), port 5432 failed: fe_sendauth: no password supplied
,我假设缺少设置数据库密码的环境变量。
It seems you have an error with your database
connection.您的
database
连接似乎有错误。 Use and replace the below code snippet with your own credentials in your settings.py
file.在您的
settings.py
文件中使用并用您自己的凭据替换以下代码片段。 Happy coding快乐编码
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'YOUR_DATABASE_NAME',
'USER': 'YOUR_DATABASE_USERNAME',
'PASSWORD': 'YOUR_DATABASE_USERNAME',
'HOST': 'localhost',
'PORT': '5432',
# Use the below Options when you have a Postgresql server with SSL.
# 'OPTIONS': {
# 'sslmode': 'require',
# }
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.