I'm new to Django and I'm making a Django app where I'm supposed to use MySQL and MongoDB through py-mongo. (I'm trying to use only py-mongo, not with mongoengine)
I created an app 'test-app' with a model 'Books' and a CRUD views which seem to work fine (all books are saved and retrieved).
However, for some reason I can't seem to find the Books back neither in the MySQL db nor the MongoDB. I'm not sure which database the model is using.
There are also settings for Redis, but even after restarting the server the model entries are there, so I guess it is not in the cache.
my settings are:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': '127.10.0.1',
'NAME': 'test_db',
'USER': 'test_user',
'PASSWORD': 'test_pass',
}
}
CACHES = {
'default': {
'BACKEND': 'redis_cache.RedisCache',
'LOCATION': '127.10.0.1:6379',
'OPTIONS': {
'DB': 0,
},
},
}
MONGODB = {
'default': {
'HOST': '127.10.0.1',
'PORT': '27017',
'NAME': 'django',
}
}
And my requirements.txt:
Django>=1.8,<1.9
docker-compose>1.11
django-redis-cache>1.7
pymongo>=3.4
MySQL-python>=1.2
The migrations file seems to have MongoDB syntax, not SQL syntax, which makes me think it is actually stored in MongoDB:
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='Book',
fields=[
('number', models.IntegerField(serialize=False, primary_key=True)),
('author', models.CharField(max_length=200)),
],
),
]