'How to change the database local to be in a cloud (Django)
I wrote a project in django framework and I use the local DataBase SQLite, and I now want to upload it to the cloud so other people who work with me can access DataBase i.e. when I create a user then that user will exist with my co-workers.
Maybe someone has a guide on how to do this without modifying the DataBase so that I do not have to modify the rest of the code?
Solution 1:[1]
Ok i found the answer, what you should do is Connect Django and MongoDB Using Djongo
you can read from here
I RECOMMEND TO FOLLOW MY SETPS.
- go to monogodb site -> clickHere and create free account.
- create new cluster
- then you will reverse to this page if no in the left side press DataBase under DEPLOYMENT and then you get.

- press on Connect buttom

- choose "Connect your application" and then choose python and the last version
after all this you will have this link: for example!!!
mongodb+srv://<username>:<password>@<atlas cluster>/<myFirstDatabase>?retryWrites=true&w=majority
copy this link and do the next setps:
- go back to your terminal and install this package:
pip install djongo - and open settings.py
- change your DATEBASE to like this:
DATABASES = { 'default': { 'ENGINE': 'djongo', 'NAME': 'your-db-name', 'CLIENT': { 'host': 'mongodb+srv://<username>:<password>@<atlascluster>/<myFirstDatabase>?retryWrites=true&w=majority' } } }
- in 'host' paste the link you copy from monogodb site.
- in 'NAME' write your name of the database.
Now that we have the Django project (and app), you can create the collections in MongoDB using the commands:
python manage.py makemigrations <app-name>
python manage.py migrate
if you get error like 'django.db.utils.databaseerror' what you should to do is: It deletes all the files that are in the migrations folder that are in the apps you have created and after that run again the command above.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Roni Jack Vituli |
