简体   繁体   中英

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. 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.

It seems you have an error with your database connection. Use and replace the below code snippet with your own credentials in your settings.py file. 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',
        # }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM