How to create or add multiple databases in django. Where always my models are created in default database .how to change it
-
Please post what you have tried.Xcoder– Xcoder2018-11-24 16:43:42 +00:00Commented Nov 24, 2018 at 16:43
-
I dint tried any. I'm blank in switching dbsGamer– Gamer2018-11-24 17:23:26 +00:00Commented Nov 24, 2018 at 17:23
-
Have you tried Google searching?Xcoder– Xcoder2018-11-24 17:27:50 +00:00Commented Nov 24, 2018 at 17:27
-
Tried googling....but dint get proper answerGamer– Gamer2018-11-24 17:32:38 +00:00Commented Nov 24, 2018 at 17:32
-
Here is a similar question I found. Maybe this can help a little...Xcoder– Xcoder2018-11-24 17:33:36 +00:00Commented Nov 24, 2018 at 17:33
|
Show 3 more comments
1 Answer
Django documentation has good reference on this
https://docs.djangoproject.com/en/2.1/topics/db/multi-db/
Once you define the databases a new database other than 'default', you can use
$ ./manage.py migrate --database=new_database_name
for performing the migration or table creation
1 Comment
Gamer
Yeah I saw those things....in my project,user wants to create a new database every time. Where in cannot cannot add those databases every time in settings...