djongo icon indicating copy to clipboard operation
djongo copied to clipboard

djongo' isn't an available database backend

Open mstgnz opened this issue 7 years ago • 84 comments

djongo' isn't an available database backend

django.core.exceptions.ImproperlyConfigured: 'djongo' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
    'mysql', 'oracle', 'postgresql', 'sqlite3'

mstgnz avatar Aug 15 '18 20:08 mstgnz

In my opinion, you need to install djongo by pip.

morenice avatar Aug 22 '18 09:08 morenice

Have the same problem.

nvishnya avatar Nov 02 '18 22:11 nvishnya

I have the same problem, how to solve it

mansoncui avatar Nov 05 '18 05:11 mansoncui

You haven't installed djongo. pip install djongo or pip3 install djongo.

thestick613 avatar Nov 12 '18 13:11 thestick613

i got the same problem as well, both commands doesnt work for me. my error: django.core.exceptions.ImproperlyConfigured: 'django.db.backends.mysql' isn't an available database backend. even though i created new database in mysql

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'blog', 'USER': 'root', 'PASSWORD': '******', 'HOST': '127.0.0.1', 'PORT': 3306, }

what could be the solution?

sabuhish avatar Jan 20 '19 10:01 sabuhish

well I solved problem by removing virtual environment and reinstalling all the packages again. it worked for me then, I have now access to mysql database

sabuhish avatar Jan 20 '19 11:01 sabuhish

well I solved problem by removing virtual environment and reinstalling all the packages again. it worked for me then, I have now access to mysql database

and how to do that? please tell me...

Error1996 avatar Mar 10 '19 12:03 Error1996

activating virtual env source venv/bin/activate to deactivate simply type deactivate P.S There is no command for deleting your virtual environment. Simply deactivate it and rid your application of its artifacts by recursively removing it.(refs link:- https://stackoverflow.com/questions/11005457/how-do-i-remove-delete-a-virtualenv)

Kushan- avatar Mar 11 '19 03:03 Kushan-

You need to install djongo using this CMD pip install djongo

pkchoudhary1211 avatar Apr 03 '19 06:04 pkchoudhary1211

The same, djongo worked fine, but after a few migrations there was an error:

django.core.exceptions.ImproperlyConfigured: 'djongo' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
    'mysql', 'oracle', 'postgresql', 'sqlite3'

django 2.2.1

UPD: I found the problem, my pycharm after restarting messed up the environment and downloading packages from the other, in which was not installed djongo, I recommend that you check the path your python environment (echo $PATH && echo $PYTHONPATH) or specify the full path: /your-environment-path/bin/python manage.py runserver or run: $ pip list

nodermann2 avatar May 24 '19 11:05 nodermann2

django.core.exceptions.ImproperlyConfigured: 'django.db.backends.cx_Oracle' isn't an available database backend. Try using 'django.db.backends.XXX', where XXX is one of: 'mysql', 'oracle', 'postgresql', 'sqlite3'

I got same problem....I installed Oracle database...can you explain how to establish connection in settings.py file....

SriVijayaDurga avatar May 28 '19 05:05 SriVijayaDurga

It's django, not djongo please guys...

garcsl avatar May 28 '19 09:05 garcsl

Having the same problem, I have verified that djongo is installed and it shows up in pip freeze / pip list:

Package     Version
----------- -------
dataclasses 0.6
Django      2.2.2
djongo      1.2.32
dnspython   1.16.0
pip         19.0.3
pytz        2019.1
setuptools  40.8.0
sqlparse    0.3.0

Not sure if this is a windows issue or not. Env:

  • Win 10
  • Python 3.7
  • Virtual Env
  • Pycharm

joewalk102 avatar Jun 13 '19 19:06 joewalk102

Absolutely same situation. Is there a way to solve it?

Having the same problem, I have verified that djongo is installed and it shows up in pip freeze / pip list:

Package     Version
----------- -------
dataclasses 0.6
Django      2.2.2
djongo      1.2.33
pip         19.0.3

pymongo 3.8.0

pytz 2019.1 setuptools 40.8.0 sqlparse 0.2.4


Not sure if this is a windows issue or not.
Env:
    * Win 10
    * Python 3.7
    * Virtual Env
    * Pycharm

xppa avatar Jun 16 '19 20:06 xppa

well I solved problem by removing virtual environment and reinstalling all the packages again. it worked for me then, I have now access to mysql database

Following the reinstalling packages advice, this worked for me:

pip uninstall -y `pip freeze`
pip install -r requirements.txt

If you do not have a requirements file already you can create it with pip freeze > requirements.txt

pablo-grande avatar Jun 21 '19 15:06 pablo-grande

I had the same issue, and I solved it by copy djongo folder to my project. and it's work.

gogobook avatar Nov 13 '19 04:11 gogobook

Same here. djongo is installed with pip under virtual environment, yet it isn't picked up. Uninstalling it and reinstalling it doesn't work at all and the virtual environment is completely broken.

agiokas-dbg avatar Dec 06 '19 11:12 agiokas-dbg

Djongo is installed with pip under virtual environment, yet it isn't picked up. My django version: 3.0

Bogro avatar Dec 11 '19 09:12 Bogro

Guys, Please Use django 2.2.8 . Because djongo is not compatible with Django's latest version 3.0.

Cheers

Rajat-verma-99 avatar Dec 16 '19 09:12 Rajat-verma-99

@Rajat-verma-99
OK, thanks

Bogro avatar Dec 17 '19 15:12 Bogro

I still have the same problem after downgrading Django to v 2.2.8. I will come back here if I find out a solution.

Nebotxavi avatar Dec 17 '19 15:12 Nebotxavi

Finally I could make it by creating a new project based on Django v2.2 so the "djongo' isn't an available database backend" error was solved. After that, I had to install pymongo[srv] in order to complete the whole setup, I ran the following command: 'python -m pip install pymongo[srv]'. However, I could not fix the issue in my original project, even although I downgraded the Django version to 2.2 (and made sure the modification took effect) the "available database backend problem" was still there. I just redid the project from scratch by copy/pasting and installing the same version of everything that I had previously installed so I am not sure if the problem was the Django version or anything else...

Nebotxavi avatar Dec 17 '19 17:12 Nebotxavi

The problem is with the latest version of Django. Downgrade it to the later version i.e. version 2. command:pip install django==2

raziv10 avatar Dec 18 '19 05:12 raziv10

@Nebotxavi Could you Please share the screenshots of the error that you are facing?

Rajat-verma-99 avatar Dec 18 '19 06:12 Rajat-verma-99

`Traceback (most recent call last): File "/home/blcl/react/venv/lib/python3.6/site-packages/django/db/utils.py", line 110, in load_backend return import_module('%s.base' % backend_name) File "/usr/lib/python3.6/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 941, in _find_and_load_unlocked File "", line 219, in _call_with_frames_removed File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 953, in _find_and_load_unlocked ModuleNotFoundError: No module named 'django.db.backends.djongo'

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 "/home/blcl/react/venv/lib/python3.6/site-packages/django/core/management/init.py", line 381, in execute_from_command_line utility.execute() File "/home/blcl/react/venv/lib/python3.6/site-packages/django/core/management/init.py", line 357, in execute django.setup() File "/home/blcl/react/venv/lib/python3.6/site-packages/django/init.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/home/blcl/react/venv/lib/python3.6/site-packages/django/apps/registry.py", line 114, in populate app_config.import_models() File "/home/blcl/react/venv/lib/python3.6/site-packages/django/apps/config.py", line 211, in import_models self.models_module = import_module(models_module_name) File "/usr/lib/python3.6/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 665, in _load_unlocked File "", line 678, in exec_module File "", line 219, in _call_with_frames_removed File "/home/blcl/react/venv/lib/python3.6/site-packages/django/contrib/auth/models.py", line 2, in from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File "/home/blcl/react/venv/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 47, in class AbstractBaseUser(models.Model): File "/home/blcl/react/venv/lib/python3.6/site-packages/django/db/models/base.py", line 117, in new new_class.add_to_class('_meta', Options(meta, app_label)) File "/home/blcl/react/venv/lib/python3.6/site-packages/django/db/models/base.py", line 321, in add_to_class value.contribute_to_class(cls, name) File "/home/blcl/react/venv/lib/python3.6/site-packages/django/db/models/options.py", line 204, in contribute_to_class self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File "/home/blcl/react/venv/lib/python3.6/site-packages/django/db/init.py", line 28, in getattr return getattr(connections[DEFAULT_DB_ALIAS], item) File "/home/blcl/react/venv/lib/python3.6/site-packages/django/db/utils.py", line 201, in getitem backend = load_backend(db['ENGINE']) File "/home/blcl/react/venv/lib/python3.6/site-packages/django/db/utils.py", line 125, in load_backend ) from e_user django.core.exceptions.ImproperlyConfigured: 'django.db.backends.djongo' isn't an available database backend. Try using 'django.db.backends.XXX', where XXX is one of: 'mysql', 'oracle', 'postgresql', 'sqlite3'`

Nebotxavi avatar Dec 18 '19 17:12 Nebotxavi

Was just going through the tut for Django and wanted to try it with "djongo". Using conda for my package manager. Got same issue but then I downgraded to Django 2.2 suggested by @Nebotxavi pip uninstall django pip install django==2.2 python manage.py migrate

Was able to verify the creation of the collection on mongo

use polls switched to db polls show collections schema auth_group auth_group_permissions auth_permission auth_user auth_user_groups auth_user_user_permissions django_admin_log django_content_type django_migrations django_session

mtbiker-s avatar Dec 21 '19 07:12 mtbiker-s

This error occurs because the django utils.py file does not recognize that django is an available backend, to solve this error , please follow these steps... 1 . Go to C:\Users\User\AppData\Local\Programs\Python\Python38-32\Lib\site-packages and find the djongo folder . 2. Now cut and paste the djongo folder in the C:\Users\aman\AppData\Local\Programs\Python\Python38-32\Lib\site - packages\django\db\backends directory . 3. Now u might be getting the error cannot import six from django.utils. For resolving that go to C:\Users\aman\AppData\Local\Programs\Python\Python38-32\Lib\site - packages\django\db\backends\djongo\operations.py file and replace the line from django.utils import six , datetime to from django.utils import datetime and beneath that just write import six . 4. Now in the settings.py file of your django project add the lines DATABASES = { 'default': { 'ENGINE': 'django.db.backends.djongo', 'NAME': 'your-database-name', } } 5. That should resolve the problem ....

aaman123 avatar Jan 06 '20 10:01 aaman123

For me it worked with

Django==3.0.3
djongo==1.3.1
pymongo==3.10.1


Basically when you pip3 install djongo you get required dependencies and things works fine even with Django 3.*

parin13 avatar Feb 27 '20 10:02 parin13

Using python3.8 in my virtual environment fixed my issues with djongo isn't an available database backend

bernardassan avatar Mar 12 '20 02:03 bernardassan

Uninstall pymongo and installing the 3.7.2 version, it worked for me:

#pip uninstall pymongo #pip install pymongo==3.7.2

iibarguen12 avatar Mar 26 '20 14:03 iibarguen12