I have written a django application with mongodb as backend, created models and used DJONGO to setup the ORM, below is my settings.py
DATABASES = {
'default': {
'ENGINE': 'djongo',
'NAME': 'conversations',
'HOST':'mongodb+srv://userName:password@clusterx-abcde.mongodb.net/dbName?retryWrites=true&w=majority',
'USER':'userName',
'PASSWORD':'password'
}
}
I had to end up modifying host from localhost to 'mongodb+srv://userName:password@clusterx-abcde.mongodb.net/dbName?retryWrites=true&w=majority' in mongo_clients.py(pymongo package).
Django cant connect to mongoDB atlas https://github.com/nesdis/djongo/issues/132
Above are the links I referred to, to change host on mongo_clients.py
This application works fine on my local machine, once I host it on azure, during the build azure is modifying the mongo_clients.py and changing the host to localhost making my application not work as expected.
class MongoClient(common.BaseObject):
"""
A client-side representation of a MongoDB cluster.
Instances can represent either a standalone MongoDB server, a replica
set, or a sharded cluster. Instances of this class are responsible for
maintaining up-to-date state of the cluster, and possibly cache
resources related to this, including background threads for monitoring,
and connection pools.
"""
HOST = 'mongodb+srv://userName:password@clusterx-abcde.mongodb.net/dbName?retryWrites=true&w=majority'
PORT = 27017
# Define order to retrieve options from ClientOptions for __repr__.
# No host/port; these are retrieved from TopologySettings.
_constructor_args = ('document_class', 'tz_aware', 'connect')
Is there anyway to have azure ignore these changes I made on mongo_client.py, it's part of pymongo package