I am trying to create dynamic website using Django.For dynamic data i have tried to use mongodb Database.For the connection between mongo db and django ,djongo is used here.
After defining the database and tried to the command makemigrations it shows the error.
Data definition in Settings file.py
DATABASES = { 'default': { 'ENGINE': 'djongo', 'NAME': 'Cake_Bakery', 'CLIENT':{'host':'localhost','port':27017} } }
error is given below:
(cake) PS D:\Cake Eccomerce\cake\Cake_Bakery> python manage.py makemigrations
System check identified some issues:
WARNINGS:
?: (urls.W002) Your URL pattern '/products' [name='products'] has a route beginning with a '/'. Remove this slash as it is unnecessary. If this pattern is targeted in an include(), ensure the include() pattern has a trailing '/'.
No changes detected
Traceback (most recent call last):
File "D:\Cake Eccomerce\cake\Cake_Bakery\manage.py", line 22, in <module>
main()
File "D:\Cake Eccomerce\cake\Cake_Bakery\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "D:\Cake Eccomerce\cake\Lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
utility.execute()
File "D:\Cake Eccomerce\cake\Lib\site-packages\django\core\management\__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\Cake Eccomerce\cake\Lib\site-packages\django\core\management\base.py", line 415, in run_from_argv
connections.close_all()
File "D:\Cake Eccomerce\cake\Lib\site-packages\django\utils\connection.py", line 85, in close_all
conn.close()
File "D:\Cake Eccomerce\cake\Lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "D:\Cake Eccomerce\cake\Lib\site-packages\django\db\backends\base\base.py", line 358, in close
self._close()
File "D:\Cake Eccomerce\cake\Lib\site-packages\djongo\base.py", line 208, in _close
if self.connection:
File "D:\Cake Eccomerce\cake\Lib\site-packages\pymongo\database.py", line 1337, in __bool__
raise NotImplementedError(
NotImplementedError: Database objects do not implement truth value testing or bool(). Please compare with None instead: database is not None
(cake) PS D:\Cake Eccomerce\cake\Cake_Bakery>
How to rectify the above error .
djongo version used here is :1.3.6v django version used here is 4.1.13v mongo db downloaded version is :7.0.3
The problem is with the new version of pymongo (4.0 from 29.11.2021) which is not supported by Djongo 1.3.6. You need to install pymongo 3.12.1.
Install pymongo version