I just tried to find a solution for define database model wise in Django. 
like in my settings.py there are three databases

settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    },
    'db_one': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db_one.sqlite3'),
    },
    'db_two': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db_two.sqlite3'),
    },}

And in my polls/models.py

class Question(models.Model):
    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')


    def __str__(self):
        return self.question_text

    def was_published_recently(self):
        return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
@python_2_unicode_compatibleclass Choice(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)


    def __str__(self):
        return self.choice_text

now I want to add question model in db_one database and Choice model in 
db_two database so how can I do that

I try with routers follow this multiple databases and multiple models in 
Django 
<https://stackoverflow.com/questions/18547468/multiple-databases-and-multiple-models-in-django>
 but 
it prefers only default database only after that i tried with put blank 
setting in default database and try ti migrate but it gives me an error

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/10ce81e3-674f-4c2e-b4ad-0215f3d1aff2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to