Im trying to implement MongoDB in my Django app like this:
DATABASES = {
'default': {
'ENGINE': 'djongo',
'NAME': 'mongodb',
}
}
But I get this error:
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [WinError 10061]
No connection could be made because the target machine actively refused it
Traceback:
Traceback (most recent call last):
File "c:\users\...\appdata\local\continuum\anaconda3\Lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "c:\users\...\appdata\local\continuum\anaconda3\Lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "D:\Users\...\env\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "D:\Users\...\env\lib\site-packages\django\core\management\commands\runserver.py", line 120, in inner_run
self.check_migrations()
File "D:\Users\...\env\lib\site-packages\django\core\management\base.py", line 453, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "D:\Users\...\env\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "D:\Users\...\env\lib\site-packages\django\db\migrations\loader.py", line 49, in __init__
self.build_graph()
File "D:\Users\...\env\lib\site-packages\django\db\migrations\loader.py", line 212, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "D:\Users\...\env\lib\site-packages\django\db\migrations\recorder.py", line 73, in applied_migrations
if self.has_table():
File "D:\Users\...\env\lib\site-packages\django\db\migrations\recorder.py", line 56, in has_table
return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
File "D:\Users\...\env\lib\site-packages\django\db\backends\base\introspection.py", line 48, in table_names
return get_names(cursor)
File "D:\Users\...\env\lib\site-packages\django\db\backends\base\introspection.py", line 43, in get_names
return sorted(ti.name for ti in self.get_table_list(cursor)
File "D:\Users\...\env\lib\site-packages\djongo\introspection.py", line 46, in get_table_list
for c in cursor.db_conn.list_collection_names()
File "D:\Users\...\env\lib\site-packages\pymongo\database.py", line 856, in list_collection_names
for result in self.list_collections(session=session, **kwargs)]
File "D:\Users\...\env\lib\site-packages\pymongo\database.py", line 819, in list_collections
_cmd, read_pref, session)
File "D:\Users\...\env\lib\site-packages\pymongo\mongo_client.py", line 1454, in _retryable_read
read_pref, session, address=address)
File "D:\Users\...\env\lib\site-packages\pymongo\mongo_client.py", line 1253, in _select_server
server = topology.select_server(server_selector)
File "D:\Users\...\env\lib\site-packages\pymongo\topology.py", line 235, in select_server
address))
File "D:\Users\...\env\lib\site-packages\pymongo\topology.py", line 193, in select_servers
selector, server_timeout, address)
File "D:\Users\...\env\lib\site-packages\pymongo\topology.py", line 209, in _select_servers_loop
self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [WinError 10061]
No connection could be made because the target machine actively refused it
Thank you very much for any help
Check first that you passed through all these steps
Try changing port of mongodb , that will make it work hopefully :)
1) pip install djongo
2) DATABASES = {
'default': {
'ENGINE': 'djongo',
'NAME': 'your-db-name',
}
}
3) python manage.py makemigrations
4) python manage.py migrate
Related
"django.db.utils.OperationalError" occurred while setting using django cookiecutter.
config\settings\base.py
DATABASES = {
"default": env.db(
"DATABASE_URL",
default="postgres://postgres:root#localhost:5432/instagram",
),
}
C:\dev\clone\instagram>py manage.py migrate
Traceback (most recent call last):
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\backends\base\base.py", line 244, in ensure_connection
self.connect()
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\backends\base\base.py", line 225, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\backends\postgresql\base.py", line 203, in get_new_connection
connection = Database.connect(**conn_params)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\psycopg2\__init__.py", line 122, 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:\dev\clone\instagram\manage.py", line 31, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
utility.execute()
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 414, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 460, in execute
output = self.handle(*args, **options)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 98, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\commands\migrate.py", line 91, in handle
self.check(databases=[database])
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 487, in check
all_issues = checks.run_checks(
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\checks\registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\checks\model_checks.py", line 36, in check_all_models
errors.extend(model.check(**kwargs))
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\models\base.py", line 1461, in check
*cls._check_indexes(databases),
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\models\base.py", line 1864, in _check_indexes
connection.features.supports_covering_indexes
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\functional.py", line 49, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\backends\postgresql\features.py", line 84, in is_postgresql_11
return self.connection.pg_version >= 110000
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\functional.py", line 49, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\backends\postgresql\base.py", line 354, in pg_version
with self.temporary_connection():
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 135, in __enter__
return next(self.gen)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\backends\base\base.py", line 639, in temporary_connection
with self.cursor() as cursor:
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\backends\base\base.py", line 284, in cursor
return self._cursor()
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\backends\base\base.py", line 260, in _cursor
self.ensure_connection()
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\backends\base\base.py", line 243, in ensure_connection
with self.wrap_database_errors:
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\backends\base\base.py", line 244, in ensure_connection
self.connect()
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\backends\base\base.py", line 225, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\backends\postgresql\base.py", line 203, in get_new_connection
connection = Database.connect(**conn_params)
File "C:\Users\krsai\AppData\Local\Programs\Python\Python310\lib\site-packages\psycopg2\__init__.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError
I modified only this base.py part, but the "migrate" command is not executed and an error occurs. What is the reason?
installed postgresql
create DB name as "instagram"
installed cookiecutter
modified "base.py"
run "py manage.py makemigrations"
error occured
Now I'm using postgresql version 15, could it be the reason of error?
Because I tried to use version 14 also but have same error.
Remove all the migration files, then:
python manage.py makemigrations
python manage.py migrate
I am learning to use Django through a tutorial in which we are developing a small project,
i'm trying to connect a PostgresSQL database and do the migrations,
but i have certain problems when doing 'python manage.py migrate' in the terminal
Settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'DEMO_TEST',
'USER' : 'postgresql',
'HOST': 'localhost',
'PASSWORD':'le123le123',
'PORT': '5432',
}
}
Traceback
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
self.connect()
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\db\backends\base\base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\db\backends\postgresql\base.py", line 187, in get_new_connection
connection = Database.connect(**conn_params)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\psycopg2\__init__.py", line 122, 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 "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\core\management\__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\core\management\base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\core\management\base.py", line 398, in execute
output = self.handle(*args, **options)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\core\management\base.py", line 89, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\core\management\commands\migrate.py", line 75, in handle
self.check(databases=[database])
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\core\management\base.py", line 419, in check
all_issues = checks.run_checks(
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\core\checks\registry.py", line 76, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\core\checks\model_checks.py", line 34, in check_all_models
errors.extend(model.check(**kwargs))
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\db\models\base.py", line 1290, in check
*cls._check_indexes(databases),
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\db\models\base.py", line 1680, in _check_indexes
connection.features.supports_covering_indexes or
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\db\backends\postgresql\features.py", line 93, in is_postgresql_11
return self.connection.pg_version >= 110000
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\db\backends\postgresql\base.py", line 329, in pg_version
with self.temporary_connection():
File "C:\Users\le\anaconda3\envs\myenv\lib\contextlib.py", line 113, in __enter__
return next(self.gen)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\db\backends\base\base.py", line 603, in temporary_connection
with self.cursor() as cursor:
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\db\backends\base\base.py", line 259, in cursor
return self._cursor()
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\db\backends\base\base.py", line 235, in _cursor
self.ensure_connection()
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
self.connect()
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\db\utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
self.connect()
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\db\backends\base\base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\django\db\backends\postgresql\base.py", line 187, in get_new_connection
connection = Database.connect(**conn_params)
File "C:\Users\le\anaconda3\envs\myenv\lib\site-packages\psycopg2\__init__.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError
Create the account in PostgreSQL and try to link it with Django to have the tables that I have already created in Sqlite3. Someone help me please
I am trying to host my website on digitaloceans. on running
python manage.py makeigrations
I get these errors
Traceback (most recent call last):
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 187, in get_new_connection
connection = Database.connect(**conn_params)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL: password authentication failed for user "djangoadmin"
FATAL: password authentication failed for user "djangoadmin"
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/core/management/base.py", line 85, in wrapped
res = handle_func(*args, **kwargs)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/core/management/commands/makemigrations.py", line 101, in handle
loader.check_consistent_history(connection)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 290, in check_consistent_history
applied = recorder.applied_migrations()
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 77, in applied_migrations
if self.has_table():
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 55, in has_table
with self.connection.cursor() as cursor:
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 259, in cursor
return self._cursor()
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 235, in _cursor
self.ensure_connection()
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 187, in get_new_connection
connection = Database.connect(**conn_params)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: FATAL: password authentication failed for user "djangoadmin"
FATAL: password authentication failed for user "djangoadmin"
(venv) djangoadmin#ubuntu-s-1vcpu-1gb-nyc1-01:~/pyapps/pilgrimage_church$ sudo nano .env
[sudo] password for djangoadmin:
(venv) djangoadmin#ubuntu-s-1vcpu-1gb-nyc1-01:~/pyapps/pilgrimage_church$ python manage.py makemigrations
Traceback (most recent call last):
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 187, in get_new_connection
connection = Database.connect(**conn_params)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL: password authentication failed for user "djangoadmin"
FATAL: password authentication failed for user "djangoadmin"
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/core/management/base.py", line 85, in wrapped
res = handle_func(*args, **kwargs)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/core/management/commands/makemigrations.py", line 101, in handle
loader.check_consistent_history(connection)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 290, in check_consistent_history
applied = recorder.applied_migrations()
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 77, in applied_migrations
if self.has_table():
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 55, in has_table
with self.connection.cursor() as cursor:
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 259, in cursor
return self._cursor()
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 235, in _cursor
self.ensure_connection()
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/backends/base/base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 187, in get_new_connection
connection = Database.connect(**conn_params)
File "/home/djangoadmin/pyapps/venv/lib/python3.6/site-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: FATAL: password authentication failed for user "djangoadmin"
FATAL: password authentication failed for user "djangoadmin"
djangoadmin is not in my database at all. I am using Postgresql as my database
However, django admin is an ssh user.
Django database settings:
DATABASES = { 'default':
{ 'ENGINE': 'django.db.backends.postgresql',
'NAME': env.str('NAME'),
'USER': env.str('USER'),
'PASSWORD': env.str('PASSWORD'),
'HOST': 'localhost',
'PORT': '5432', } }
What can I do please? I have reset the password. I have dropped and created a new table. I keep getting this error
I have a hard time because I'm a django beginner.
Please share your wisdom in solving this problem.
python3 manage.py runserver
Problems arise when a project is executed.
I don't know the cause of the problem
settings.py
import os
from dotenv import load_dotenv
load_dotenv()
...
SECRET_KEY = os.getenv('SECRET_KEY')
DEBUG=os.getenv('DEBUG')
DATABASES = {
'default': {
'ENGINE': os.getenv('DB_ENGINE'),
'NAME': os.getenv('DB_NAME'),
'USER': os.getenv('DB_USER'),
'PASSWORD': os.getenv('DB_PASSWORD'),
'HOST': os.getenv('DB_HOST'),
'PORT': os.getenv('DB_PORT'),
}
}
...
and then I met this error message.
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/config.py", line 562, in configure
handler = self.configure_handler(handlers[name])
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/config.py", line 735, in configure_handler
result = factory(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/handlers.py", line 148, in __init__
BaseRotatingHandler.__init__(self, filename, mode, encoding, delay)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/handlers.py", line 55, in __init__
logging.FileHandler.__init__(self, filename, mode, encoding, delay)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/__init__.py", line 1087, in __init__
StreamHandler.__init__(self, self._open())
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/__init__.py", line 1116, in _open
return open(self.baseFilename, self.mode, encoding=self.encoding)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/haemil/Desktop/Back-end workspace/Django_workspace/asone/logs/logfile'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/Users/haemil/Desktop/Back-end workspace/Django_workspace/asone/venv/lib/python3.7/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/Users/haemil/Desktop/Back-end workspace/Django_workspace/asone/venv/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "/Users/haemil/Desktop/Back-end workspace/Django_workspace/asone/venv/lib/python3.7/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "/Users/haemil/Desktop/Back-end workspace/Django_workspace/asone/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "/Users/haemil/Desktop/Back-end workspace/Django_workspace/asone/venv/lib/python3.7/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/Users/haemil/Desktop/Back-end workspace/Django_workspace/asone/venv/lib/python3.7/site-packages/django/__init__.py", line 19, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/Users/haemil/Desktop/Back-end workspace/Django_workspace/asone/venv/lib/python3.7/site-packages/django/utils/log.py", line 75, in configure_logging
logging_config_func(logging_settings)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/config.py", line 799, in dictConfig
dictConfigClass(config).configure()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/config.py", line 570, in configure
'%r' % name) from e
ValueError: Unable to configure handler 'file'
Is there something I'm missing?
What more information will be needed to solve this problem?
I'm sorry to send you a question with a little information.
thank you for watching
I'm waiting for answer
I am using djongo with django2 to connect to mlab mongodb instance.
settings.py
'default': {
'ENGINE': 'djongo',
'NAME': 'neon',
'HOST': 'mongodb://username:password#ds249605.mlab.com:49605/mlab1',
}
}
although I am using this settings, the PyMongo connects to the local instance of mongodb.
log
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run
self.check_migrations()
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/core/management/base.py", line 453, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/db/migrations/loader.py", line 212, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/db/migrations/recorder.py", line 73, in applied_migrations
if self.has_table():
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/db/migrations/recorder.py", line 56, in has_table
return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/db/backends/base/introspection.py", line 48, in table_names
return get_names(cursor)
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/django/db/backends/base/introspection.py", line 43, in get_names
return sorted(ti.name for ti in self.get_table_list(cursor)
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/djongo/introspection.py", line 47, in get_table_list
for c in cursor.db_conn.list_collection_names()
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/pymongo/database.py", line 856, in list_collection_names
for result in self.list_collections(session=session, **kwargs)]
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/pymongo/database.py", line 819, in list_collections
_cmd, read_pref, session)
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/pymongo/mongo_client.py", line 1454, in _retryable_read
read_pref, session, address=address)
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/pymongo/mongo_client.py", line 1253, in _select_server
server = topology.select_server(server_selector)
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/pymongo/topology.py", line 235, in select_server
address))
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/pymongo/topology.py", line 193, in select_servers
selector, server_timeout, address)
File "/home/rahul/projects/django/neon/lib/python3.7/site-packages/pymongo/topology.py", line 209, in _select_servers_loop
self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused
mLab
The host be inside client like this
DATABASES = {
'default': {
'ENGINE': 'djongo',
'NAME': 'fitbitt',
'CLIENT': {
'host':'mongodb://your_username:your_password#ds363008.mlab.com:63008/fitbitt',
'username':'your_username',
'password':'your_password'
}
}
}