I successfully connected my Django app on my computer to Mlab using Djongo and the homepage on my localhost:8000 server seems to be displaying correctly. However, when I run 'py manage.py migrate', it gives a long list of errors in the terminal and I am not sure how to properly connect to the Mlabs database and populate it with data from the terminal of my Django app in my local computer. How do I migrate the database information onto my Mlab database? I'm not sure what the error is. I'm a little new to Django and MongoDB.
This is a part of the error I see:
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\cursor.py", line 51, in execute
self.result = Query(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 783, in __init__
self._query = self.parse()
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 868, in parse
raise exe from e
djongo.exceptions.SQLDecodeError:
Keyword: None
Sub SQL: None
FAILED SQL: INSERT INTO "django_migrations" ("app", "name", "applied") VALUES (%(0)s, %(1)s, %(2)s)
Params: ['contenttypes', '0001_initial', datetime.datetime(2020, 7, 29, 21, 36, 46, 283726)]
Version: 1.3.3
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\cursor.py", line 59, in execute
raise db_exe from e
djongo.database.DatabaseError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\migrate.py", line 231, in handle
post_migrate_state = executor.migrate(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 246, in apply_migration
self.record_migration(migration)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 261, in record_migration
self.recorder.record_applied(migration.app_label, migration.name)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\recorder.py", line 86, in record_applied
self.migration_qs.create(app=app, name=name)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 433, in create
obj.save(force_insert=True, using=self.db)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
745, in save
self.save_base(using=using, force_insert=force_insert,
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
782, in save_base
updated = self._save_table(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
887, in _save_table
results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
924, in _do_insert
return manager._insert(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 1204, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\sql\compiler.py", line 1391, in execute_sql
PS D:\Business\Daydoa\v6-Django_with_MongoDB3\djongo_project> py manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial...This version of djongo does not support "schema validation using CONSTRAINT" fully. Visit https://www.patreon.com/nesdis
Traceback (most recent call last):
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\mongo_client.py", line 1384, in _retry_with_session
return func(session, sock_info, retryable)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\collection.py", line 2873, in _find_and_modify
out = self._command(sock_info, cmd,
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\collection.py", line 235, in _command
return sock_info.command(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\pool.py", line 603, in command
return command(self.sock, dbname, spec, slave_ok,
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\network.py", line 165, in command
helpers._check_command_response(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\helpers.py", line 159, in _check_command_response
raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: Transaction numbers are only allowed on storage engines that support document-level locking
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 856, in parse
return handler(self, statement)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 928, in _insert
query.execute()
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 374, in execute
auto = self.db['__schema__'].find_one_and_update(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\collection.py", line 3134, in find_one_and_update
return self.__find_and_modify(filter, projection,
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\collection.py", line 2884, in __find_and_modify
return self.__database.client._retryable_write(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\mongo_client.py", line 1491, in _retryable_write
return self._retry_with_session(retryable, func, s, None)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\mongo_client.py", line 1425, in _retry_with_session
raise OperationFailure(errmsg, exc.code, exc.details)
pymongo.errors.OperationFailure: This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\cursor.py", line 51, in execute
self.result = Query(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 783, in __init__
self._query = self.parse()
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 868, in parse
raise exe from e
djongo.exceptions.SQLDecodeError:
Keyword: None
Sub SQL: None
FAILED SQL: INSERT INTO "django_migrations" ("app", "name", "applied") VALUES (%(0)s, %(1)s, %(2)s)
Params: ['contenttypes', '0001_initial', datetime.datetime(2020, 7, 29, 21, 37, 1, 197586)]
Version: 1.3.3
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\cursor.py", line 59, in execute
raise db_exe from e
djongo.database.DatabaseError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\migrate.py", line 231, in handle
post_migrate_state = executor.migrate(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 246, in apply_migration
self.record_migration(migration)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 261, in record_migration
self.recorder.record_applied(migration.app_label, migration.name)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\recorder.py", line 86, in record_applied
self.migration_qs.create(app=app, name=name)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 433, in create
obj.save(force_insert=True, using=self.db)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
745, in save
self.save_base(using=using, force_insert=force_insert,
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
782, in save_base
updated = self._save_table(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
887, in _save_table
results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
924, in _do_insert
return manager._insert(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 1204, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\sql\compiler.py", line 1391, in execute_sql
cursor.execute(sql, params)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 100, in execute
return super().execute(sql, params)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\cursor.py", line 59, in execute
raise db_exe from e
django.db.utils.DatabaseError