2

I am using mongoengine with Django and my project needs to connect to one instances of MongoDB while another with sql .How my databse section of setting.py should be like ?

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'admin_db', 'USER': 'root', 'PASSWORD': 'root', 'HOST': 'localhost', }, } from mongoengine import connect connect( db='pom', username='admin', password='root', host='mongodb://admin:root@localhost' ) 
3
  • Which is your default database?? mysql or mongo db?? Commented Jul 7, 2017 at 6:19
  • Are you using django-nonrel? Commented Jul 7, 2017 at 6:25
  • i wan to use both mongodb and sql databases. My default databases is sql and no,i am not using django-nonrel instead of that i am using MongoEngine Commented Jul 7, 2017 at 7:07

2 Answers 2

1

You could add multiple databases for your app in your settings.py like,

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'admin_db', 'USER': 'root', 'PASSWORD': 'root', 'HOST': 'localhost', }, 'your_desired_db_name' : { 'ENGINE' : 'django_mongodb_engine', 'NAME' : 'db_name' } 

For integration with mongodb, you may need to look up,

Also, you may need to look up Django documentation for multiple databases

Sign up to request clarification or add additional context in comments.

1 Comment

i am using django1.8 and Django-MongoEngine is not used for django 1.8 so for integration i am using MongoEngine. so i need my setting.py file accoding to MongoEngine.
1

MongoEngine does not support all Django contrib modules directly. If your projects dont need them (unlikely) you can use mongoengine directly. Otherwise you can also try

Which seems to work fine with the latest Django version.

3 Comments

We are trying to use Djongo but it is not working as expected. I have posted an issue in your repo.
This does not look to be a problem with djongo, rather your script. Logging into admin is a basic operation. Works fine on my setup.
Please look at this question that I asked stackoverflow.com/questions/50700546/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.