Django.fun

Problem with importing new Mongo database into the server

I have a Django-based website on the server. I am not really professional at this btw! So, I started the website on the server showing some data from MongoDB. This time I would like to change the DB to the newer one. This is what I am doing:

First I drop the last DB: (On venv):

$ mongo <db_name> --eval 'db.aggregation__class.drop'

Then I scr (the new db) JSON-exported file into a server directory. Then I call the mongo to activate that new db:

$ mongoimport --db <new db name> --collection <new db collection name> --file <server directory>

I also checked if the db is activated by this:

$ mongo <new db name> --eval

And it is working.

The problem is when I am calling it in the views.py, it does not show that it is connecting to the new db. Consider the fact that it was working with the last db!

views.py

# connect to MongoDb Database
myclient = MongoClient(port=27017)
mydatabase = myclient[db_name]
classagg = mydatabase['aggregation__class']
database_text = classagg.find()

Any suggestion would be appreciated. Thanks

Answers: 0