I am new to django and struggling when i connected it to mongodb using djongo..i am getting a bug whenever i try to migrate. The bug is in the description. someone opplease help!

903 views
Skip to first unread message

18CSE508

unread,
Jul 21, 2020, 11:39:13 AM7/21/20
to django CMS users

Apply all migrations: admin, auth, contenttypes, pages, sessions
Running migrations:
Applying pages.0001_initial...This version of djongo does not support "NULL, NOT NULL column validation check" fully. Visit https://www.patreon.com/nesdis
Traceback (most recent call last):
File "C:\Users\Personal\Envs\projects\lib\site-packages\djongo\sql2mongo\query.py", line 856, in parse
return handler(self, statement)
File "C:\Users\Personal\Envs\projects\lib\site-packages\djongo\sql2mongo\query.py", line 897, in _create
query = CreateQuery(self.db, self.connection_properties, sm, self._params)
File "C:\Users\Personal\Envs\projects\lib\site-packages\djongo\sql2mongo\query.py", line 645, in init
super().init(*args)
File "C:\Users\Personal\Envs\projects\lib\site-packages\djongo\sql2mongo\query.py", line 84, in init
super().init(*args)
File "C:\Users\Personal\Envs\projects\lib\site-packages\djongo\sql2mongo\query.py", line 62, in init
self.parse()
File "C:\Users\Personal\Envs\projects\lib\site-packages\djongo\sql2mongo\query.py", line 729, in parse
self._create_table(statement)
File "C:\Users\Personal\Envs\projects\lib\site-packages\djongo\sql2mongo\query.py", line 704, in _create_table
self.db[table].create_index(field, unique=True, name='primary_key')
File "C:\Users\Personal\Envs\projects\lib\site-packages\pymongo\collection.py", line 1995, in create_index
self.__create_index(keys, kwargs, session, **cmd_options)
File "C:\Users\Personal\Envs\projects\lib\site-packages\pymongo\collection.py", line 1890, in __create_index
self._command(
File "C:\Users\Personal\Envs\projects\lib\site-packages\pymongo\collection.py", line 235, in _command
return sock_info.command(
File "C:\Users\Personal\Envs\projects\lib\site-packages\pymongo\pool.py", line 603, in command
return command(self.sock, dbname, spec, slave_ok,
File "C:\Users\Personal\Envs\projects\lib\site-packages\pymongo\network.py", line 165, in command
helpers._check_command_response(
File "C:\Users\Personal\Envs\projects\lib\site-packages\pymongo\helpers.py", line 159, in _check_command_response
raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: 16: Resource device

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\Personal\Envs\projects\lib\site-packages\djongo\cursor.py", line 51, in execute
self.result = Query(
File "C:\Users\Personal\Envs\projects\lib\site-packages\djongo\sql2mongo\query.py", line 783, in init
self._query = self.parse()
File "C:\Users\Personal\Envs\projects\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: CREATE TABLE "pages_weeksuggestions" ("id" int NOT NULL PRIMARY KEY AUTOINCREMENT, "title" string NOT NULL, "link" string NOT

NULL, "date" string NOT NULL, "image" string NOT NULL)
Params: None
Version: 1.3.3

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\Personal\Envs\projects\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql)
File "C:\Users\Personal\Envs\projects\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
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\Personal\Envs\projects\lib\site-packages\django\core\management_init_.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\Personal\Envs\projects\lib\site-packages\django\core\management_init_.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Personal\Envs\projects\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Personal\Envs\projects\lib\site-packages\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "C:\Users\Personal\Envs\projects\lib\site-packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Users\Personal\Envs\projects\lib\site-packages\django\core\management\commands\migrate.py", line 231, in handle
post_migrate_state = executor.migrate(
File "C:\Users\Personal\Envs\projects\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 "C:\Users\Personal\Envs\projects\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 "C:\Users\Personal\Envs\projects\lib\site-packages\django\db\migrations\executor.py", line 245, in apply_migration
state = migration.apply(state, schema_editor)
File "C:\Users\Personal\Envs\projects\lib\site-packages\django\db\migrations\migration.py", line 124, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "C:\Users\Personal\Envs\projects\lib\site-packages\django\db\migrations\operations\models.py", line 92, in database_forwards
schema_editor.create_model(model)
File "C:\Users\Personal\Envs\projects\lib\site-packages\django\db\backends\base\schema.py", line 324, in create_model
self.execute(sql, params or None)
File "C:\Users\Personal\Envs\projects\lib\site-packages\django\db\backends\base\schema.py", line 142, in execute
cursor.execute(sql, params)
File "C:\Users\Personal\Envs\projects\lib\site-packages\django\db\backends\utils.py", line 100, in execute
return super().execute(sql, params)
File "C:\Users\Personal\Envs\projects\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 "C:\Users\Personal\Envs\projects\lib\site-packages\django\db\backends\utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "C:\Users\Personal\Envs\projects\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\Personal\Envs\projects\lib\site-packages\django\db\utils.py", line 90, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\Personal\Envs\projects\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql)
File "C:\Users\Personal\Envs\projects\lib\site-packages\djongo\cursor.py", line 59, in execute
raise db_exe from e
django.db.utils.DatabaseError

I dont know how this occured

i want to migrate all the models

Jens-Erik Weber

unread,
Jul 21, 2020, 12:36:00 PM7/21/20
to django CMS users
Hi,

very easy: MongoDB is not supported by Django (unless there’s a secret 3rd party integration, which is very very unlikely as MongoDB is a NOSQL db). See https://docs.djangoproject.com/en/3.0/ref/databases/ Take PostgreSQ if you’ don’t have a good reason for taking another database.
How did you configure the database access

And probably it’s much easier to use Linux or macOS , also for getting support. But in principle it’s also possible on Windows.

18CSE508

unread,
Jul 22, 2020, 4:17:44 AM7/22/20
to django CMS users
Thank you !! But at the beginning when i used djongo package it happened to connect and things went good untill i deleted the db collections ..anyhow i started using postgres from yesterday.It is quite good .

18CSE508

unread,
Jul 22, 2020, 4:19:19 AM7/22/20
to django CMS users
yeah! this error didn't come up at beginning it came up when i deleted the db collections and migration file and then tried to migrate again

Jens-Erik Weber

unread,
Jul 22, 2020, 7:40:19 AM7/22/20
to djang...@googlegroups.com


Am 22.07.20 um 10:19 schrieb 18CSE508:
yeah! this error didn't come up at beginning it came up when i deleted the db collections and migration file and then tried to migrate again

On Wednesday, July 22, 2020 at 1:47:44 PM UTC+5:30, 18CSE508 wrote:
Thank you !! But at the beginning when i used djongo package it happened to connect and things went good untill i deleted the db collections ..anyhow i started using postgres from yesterday.It is quite good .
Connected to what? What is your DATABASES settings in settings.py? (Of course don’t post the password if there’s one) What did you do to connect to MongoDB, which is not really possible afaik?

18CSE508

unread,
Jul 14, 2021, 12:33:21 AM7/14/21
to django CMS users
uhmm..! sorry for the late reply. You can search about djongo package which helps in integrating mongdb and django.
Reply all
Reply to author
Forward
0 new messages