I managed to get djongo working in my local computer but when I push it to production, I need to set up an admin account for mongo so that my DB doesnt get hacked (again, sigh). Ive searched for a solution for a couple of days, without success.
This is currently the code I have, but its not working:
DATABASES = {
'default': {
'ENGINE': 'djongo',
'NAME': 'db_name',
'HOST': 'localhost',
'USERNAME': 'username',
'PASSWORD': 'password',
}
}
1) How can I configure djongo to access a DB with a username/password? I am only getting errors telling me that it wasnt able to log in to mongo.
2) Ive read a bit about "mongoengine", would you recommend I use that instead of djongo? Why?
Use this format for the Database Configuration
DATABASES = {
'default': {
"ENGINE": "djongo",
"CLIENT": {
"host": "mongodb+srv://<user_name>:<password>@<host_url>/?retryWrites=true&w=majority",
"username": "<user_name>",
"password": "<password>",
"name": "<db_name>",
"authMechanism": "SCRAM-SHA-1", #Add this line if you are using Mongo Atlas Cloud DB
},
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.