K
K
k0r0g2021-05-01 16:56:46
Django
k0r0g, 2021-05-01 16:56:46

How to specify a database for saving a model?

There are 2 sites. Each of them has 2 databases for itself and there is another common one. There is only one table in total.
In the settings of each site, I specified a second base in addition to default:

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

In the models of one of the sites, I made a test model for a common table, in the future I plan to import it into the second site:
class Registration(models.Model):
    aa = models.CharField('fdg', name="fddf", max_length=10)

    def __str__(self):
        return self.aa

Actually, the question is: how to specify the database in the model for saving from the admin panel? It's from the admin.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-05-01
@k0r0g

Routing register https://docs.djangoproject.com/en/3.2/topics/db/mu...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question