Reputation: 146
I am currently developing an application in Django+MongoDb. The application has to just push the data into the database once the url of the application is accessed.
But how ever I am encountering this error mongoengine.connection.ConnectionError: Cannot connect to database default : port must be an instance of int
As the error states port should be an 'int', I changed the port details from mongoengine.connect('employeedb', host='127.0.0.1', port='8000')
to
mongoengine.connect('employeedb', host='127.0.0.1', port=8000)
in my settings.py file but then I get an error stating mongoengine.connection.ConnectionError: Cannot connect to database default : [Errno 111] Connection refused
Can anyone find out what is going wrong here?
I am using: django==1.7, mongoengine, django-toolbox & pymongo==2.8
My settings.py file is here
EDIT: My OS= Ubuntu 14.04 & I have not installed django-nonrel
Upvotes: 1
Views: 1372
Reputation: 2990
Install mongodb in local pc and set dbpath,
Then open cmd and open connection using this command:
c:/mongodb/bin>mongod --dbpath (path of db)
and then replace you connection line in settings.py like this and run your project.
mongoengine.connect('employeedb', username='', password='')
Let me know.
Upvotes: 1
Reputation: 167
Try replacing dummy database from DATABASES dict with the following, should work for you.
DATABASES = {
'default' : {
'ENGINE' : 'django_mongodb_engine',
'NAME' : 'employeedb'
}
}
Django MongoDB Engine also takes into account the HOST, PORT, USER, PASSWORD and OPTIONS settings.
For more help https://django-mongodb-engine.readthedocs.org/en/latest/reference/settings.html
Upvotes: 0