Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

djongo' isn't an available database backend #171

Open
mstgnz opened this issue Aug 15, 2018 · 80 comments
Open

djongo' isn't an available database backend #171

mstgnz opened this issue Aug 15, 2018 · 80 comments

Comments

@mstgnz
Copy link

mstgnz commented Aug 15, 2018

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'
@morenice
Copy link

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

@nvishnya
Copy link

nvishnya commented Nov 2, 2018

Have the same problem.

@mansoncui
Copy link

I have the same problem, how to solve it

@thestick613
Copy link

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

@sabuhish
Copy link

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
Copy link

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

@Error1996
Copy link

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...

@Kushan-
Copy link

Kushan- commented Mar 11, 2019

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)

@pkchoudhary1211
Copy link

You need to install djongo using this CMD
pip install djongo

@nodermann2
Copy link

nodermann2 commented May 24, 2019

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

@SriVijayaDurga
Copy link

SriVijayaDurga commented May 28, 2019

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....

@garcsl
Copy link

garcsl commented May 28, 2019

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

@joewalk102
Copy link

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

@xppa
Copy link

xppa commented Jun 16, 2019

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

@pablo-grande
Copy link

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

@gogobook
Copy link

gogobook commented Nov 13, 2019

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

@agiokas-dbg
Copy link

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.

@Bogro
Copy link

Bogro commented Dec 11, 2019

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

@Rajat-verma-99
Copy link

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

Cheers

@Bogro
Copy link

Bogro commented Dec 17, 2019

@Rajat-verma-99
OK, thanks

@Nebotxavi
Copy link

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
Copy link

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...

@raziv10
Copy link

raziv10 commented Dec 18, 2019

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

@Rajat-verma-99
Copy link

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

@Nebotxavi
Copy link

`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'`

@mtbiker-s
Copy link

mtbiker-s commented Dec 21, 2019

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

@aaman123
Copy link

aaman123 commented Jan 6, 2020

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 ....

@parin13
Copy link

parin13 commented Feb 27, 2020

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.*

@Ultra-Code
Copy link

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

@Softiago
Copy link

Softiago commented Jul 6, 2021

Para mi funcionó con

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

Básicamente, cuando pip3 install djongo obtienes las dependencias requeridas y las cosas funcionan bien incluso con Django 3. *

Por si alguien esta teniendo este problema, a mi también me funcionó esta solución

@nicolascortegoso
Copy link

As well for me, it works with Mongodb Atlas
Django==3.0.3
djongo==1.3.1
pymongo==3.10.1

@aria3211
Copy link

Hello guys,look I'd recommendation write pip install makemigrations in your poweshell(if you use windows)
I tested in powershell and worked .

@SST-Bappu
Copy link

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'

Well, I got the same problem with my pipenv activated. Later, I figured out djongo was not installed in my pipenv. I just installed it. It's been working fine now.
(pipenv install djongo)

@rajeevkndl
Copy link

rajeevkndl commented Jan 15, 2022

i did -
django==4.0.1
pymongo==3.12.1
djongo==1.3.6

i got the same error and somewhere in between this was written -

ModuleNotFoundError: No module named 'pytz'

i did pip install pytz and it worked for me.

@viveksudani
Copy link

Django==4.0.2
pymongo==3.12.1
djongo==1.3.6
pytz==2021.3

this works perfectly fine!

@Jaspreet8843
Copy link

The solution I found is to run makemigrations from powershell without the env.

@tanmaypanda-14
Copy link

tanmaypanda-14 commented Mar 23, 2022

https://gist.github.com/uneconomicalfairy14/0d23275414122217c65882a56a30d615

this is a sure solution to this problem

@tanmaypanda-14
Copy link

what exactly is the problem send in the errors

@ProbStub
Copy link

https://gist.github.com/uneconomicalfairy14/0d23275414122217c65882a56a30d615

this is a sure solution to this problem

This looks like a good configuration. Thank you!

@ParvaPatel
Copy link

@uneconomicalfairy14 ** uneconomicalfairy14**

It's not working for me, can anyone help?

@whonayem01
Copy link

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

it worked for me

@davoodghaffarilive
Copy link

i did - django==4.0.1 pymongo==3.12.1 djongo==1.3.6

i got the same error and somewhere in between this was written -

ModuleNotFoundError: No module named 'pytz'

i did pip install pytz and it worked for me.

i think it should be in documents :/
it takes about 1 hour of my time 🗡️

@quocthinhle
Copy link

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

lol

@Jogibaer1963
Copy link

Jogibaer1963 commented Jul 31, 2022

i did pip install pytz and it worked for me.

It worked for me too

@davoodghaffarilive Big Thank you

Would be cool if mongodB support came out of the box.

@EM995
Copy link

EM995 commented Aug 8, 2022

installing 'pip install pytz' worked for me!

@anuragregmi
Copy link

installing pytz worked for me too

@felipeinstructure
Copy link

felipeinstructure commented Sep 8, 2022

It worked for me:
Django==2.1
djongo==1.3.6
pymongo==3.12.3
pytz==2022.2.1

@ht21992
Copy link

ht21992 commented Sep 14, 2022

https://gist.github.com/uneconomicalfairy14/0d23275414122217c65882a56a30d615

this is a sure solution to this problem

This works fine thanks

@kasaiee
Copy link

kasaiee commented Nov 27, 2022

django installed by djongo as a dependency. just remove any installation of django and try to install djongo

pip uninstall django
pip uninstall djongo
pip install django

@james-hollingsworth
Copy link

In my case it was because the pip install of djongo didn't install the pytz dependency

>>> import djongo.base
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/james/.local/share/virtualenvs/djangopoc-mongodb-nPt-MWsW/lib/python3.8/site-packages/djongo/base.py", line 15, in <module>
    from .operations import DatabaseOperations
  File "/home/james/.local/share/virtualenvs/djangopoc-mongodb-nPt-MWsW/lib/python3.8/site-packages/djongo/operations.py", line 1, in <module>
    import pytz
ModuleNotFoundError: No module named 'pytz'

Installing the missing dependency solved the issue. So if re-installing djongo doesn't resolve the issue I'd suggest trying to import djongo.base within your virtualenv and see if any dependencies are missing.

@stingermissile
Copy link

What I found was that the venv Lib/site-packages/django/db/backends needs to have the djongo lib installed there. I simply copied the Lib/site-packages/djongo folder into the backends folder and it works. Hope this helps!

@hemrajmalhi
Copy link

some updated version of Pymongo is not compatible with Django so you can either downgrade the Django version or upgrade the Pymongo version to a compatible version.

@Raybool
Copy link

Raybool commented Sep 10, 2023

This pitz is sh#t... I spent 2 days to find this problem...
I think, pitz - base problem in all case.
Write in console:
pip install pitz
And you will be happy
Good luck to all :)

@Simontagbor
Copy link

https://gist.github.com/uneconomicalfairy14/0d23275414122217c65882a56a30d615

this is a sure solution to this problem

Link returns 404 error

@tanmaypanda-14
Copy link

https://gist.github.com/uneconomicalfairy14/0d23275414122217c65882a56a30d615
this is a sure solution to this problem

Link returns 404 error

https://gist.github.com/tanmaypanda-14/0d23275414122217c65882a56a30d615

had to change my username

sorry for the delay

@LowLevelLore
Copy link

I think that the newer versions of pymongo and djongo are not compatible:

This works:

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
django = "*"
django-crispy-forms = "*"
django-rest-framework = "*"
social-auth-app-django = "*"
social-auth-app-django-mongoengine = "*"
django-ses = "*"
djongo = "==1.3.6"
python-dotenv = "*"
djoser = "*"
pymongo = "==3.12.3"
pytz = "*"

[dev-packages]

[requires]
python_version = "3.11"

@saivineethkumar
Copy link

for me pip install pytz resolved the issue.

@itsmehemant7
Copy link

Maybe I am late to the party. But it may help you....changing pymongo version helped me but I was still unable to run the app. Then I realized that I had to add my VPS IP address to the mongoDB atlas.

@AbdelmajidBen
Copy link

try pip install djongo==1.3.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests