djongo and mysql
Hello there,
I want to use MySQL and Djongo in the same project.
#models.py
from django.db import models from djongo import models as mongo_models
I get an error because of these lines.
File "/Users/devtrk/web/python/bridge/.env/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/devtrk/web/python/bridge/.env/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models()
File "/Users/devtrk/web/python/bridge/.env/lib/python3.6/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/devtrk/web/python/bridge/account/models.py", line 8, in <module>
import djongo.models as djongo_models
File "/Users/devtrk/web/python/bridge/.env/lib/python3.6/site-packages/djongo/models/__init__.py", line 3, in <module>
from .fields import (
File "/Users/devtrk/web/python/bridge/.env/lib/python3.6/site-packages/djongo/models/fields.py", line 17, in <module>
from django.db.models.fields.mixins import FieldCacheMixin
ModuleNotFoundError: No module named 'django.db.models.fields.mixins'
In order for that to work you need to set django up for multiple databases. Check out: https://docs.djangoproject.com/en/2.0/topics/db/multi-db/. Just follow that.
When making migrations, make sure to add —database
This is not an issue with djongo.
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'test', 'USER': 'root', 'PASSWORD': '', 'HOST': 'localhost', 'PORT': '3306', 'OPTIONS': {'charset': 'utf8mb4'}, }, 'mongo': { 'ENGINE': 'djongo', 'NAME': 'test', 'HOST': '*****.mlab.com', 'PORT': 43774, 'USER': 'test', 'PASSWORD': 'test', } }
Multi connected as database. I'm running --database=mongo.
Have you written a router?
From my understanding it seems like you need to use one database / app. You importing both in the same file makes me think you are using both databases in the same app.
If you have, when is this problem occuring? When running migrations?
I did not write a router. I want to select the database manually. Yes, it gives an error in the "makemigrations" command.
Your problem is that the package django.db.models.fields.mixins does not exist.
but removing "from djongo import models as mongo_models" does not give an error.
This is simply a problem with this import: ModuleNotFoundError: No module named 'django.db.models.fields.mixins' <- this is not a package
Is this package incompatible with django 1.11?
Please link me to the documentation for: django.db.models.fields.mixins From what I can see it does not exist. Please, I don't think this has anything to do with djongo.
Yes Django is not available in 1.11. It's in 2.0.
Checked it now, I get the same error with django 1.11. That is the problem.
Just revert to djongo 1.2.23 for now and its all good. 1.2.24 is the breaking update. OR Use django 2
Running into the same issue....downgrading to 1.2.23 for now.
Django 1.8 is the minimum required for running this package
Got it. Would be helpful if it was mentioned in the Requirements in the readme :)
Thanks!