![](/img/trans.png)
[英]Django python3 manage.py runserver won't run via VSC terminal (Mac)
[英]python manage.py runserver won't run after git cloning my repo
在 git 克隆我的項目存儲庫、創建虛擬環境並安裝所有必需的要求后,我在運行 python manage.py runserver 時遇到問題。 急需回復
(.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
由於返回的錯誤是django.db.utils.OperationalError: connection to server at "localhost" (::1), port 5432 failed: fe_sendauth: no password supplied
,我假設缺少設置數據庫密碼的環境變量。
您的database
連接似乎有錯誤。 在您的settings.py
文件中使用並用您自己的憑據替換以下代碼片段。 快樂編碼
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.