- The first step to using more than one database with Django is to tell Django about the database servers you’ll be using.
- This is done using the
DATABASES
setting. This setting maps database aliases, which are a way to refer to a specific database throughout Django, to a dictionary of settings for that specific connection. The settings in the inner dictionaries are described fully in theDATABASES
documentation. - You will find the complete documentation here The first step to using more than one database with Django is to tell Django about the database servers you’ll be using. This is done using the
DATABASES
setting. This setting maps database aliases, which are a way to refer to a specific database throughout Django, to a dictionary of settings for that specific connection. The settings in the inner dictionaries are described fully in theDATABASES
documentation.Databases can have any alias you choose. However, the aliasdefault
has special significance. Django uses the database with the alias ofdefault
when no other database has been selected.The following is an examplesettings.py
snippet defining two databases – a default PostgreSQL database and a MySQL database calledusers
- https://docs.djangoproject.com/en/2.1/topics/db/multi-db/#defining-your-databases
- complete source code here
- https://github.com/GanapathiAmbore/Django-with-Multiple-databases
How to connect Django with MongoDB you will find the complete guide here https://github.com/GanapathiAmbore Django with MongoDB
Comments
Post a Comment