Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用Django在单独的postgres模式中执行迁移_Python_Python 3.x_Django_Postgresql_Database Schema - Fatal编程技术网

Python 使用Django在单独的postgres模式中执行迁移

Python 使用Django在单独的postgres模式中执行迁移,python,python-3.x,django,postgresql,database-schema,Python,Python 3.x,Django,Postgresql,Database Schema,我有一个需求,我的Django项目需要与多个postgres模式连接。 例如:如果我们有20个DB表,那么10个将保留在public模式中,其他10个将保留在project\u one模式中。所有这些表都需要在两个单独的模式中分别使用django迁移创建 在运行迁移的同时,我还需要为python manage.py migrate提供一些选项,以便只在那些特定的模式中创建表。或者可能是模型本身的一些设置 我们如何才能做到这一点 我的默认设置如下所示 DATABASES = { 'defa

我有一个需求,我的Django项目需要与多个postgres模式连接。 例如:如果我们有20个DB表,那么10个将保留在public模式中,其他10个将保留在project\u one模式中。所有这些表都需要在两个单独的模式中分别使用django迁移创建

在运行迁移的同时,我还需要为
python manage.py migrate
提供一些选项,以便只在那些特定的模式中创建表。或者可能是模型本身的一些设置

我们如何才能做到这一点

我的默认设置如下所示

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'HOST': 'localhost',
        'NAME': 'schema_proj',
        'USER': 'testing',
        'PASSWORD': '',
        'ATOMIC_REQUESTS': True,
        }
}
在我的迁移文件中-

migrations.CreateModel(
            name='Benchmarks',
            fields=[
                ('uid', models.IntegerField(serialize=False, primary_key=True)),
                ('two_digit_desc', models.CharField(null=True, max_length=255, blank=True)),
                ('month_key', models.CharField(null=True, max_length=7, blank=True)),
                ('household_registration_rate', models.FloatField(null=True, blank=True)),
                ('t90_day_return_hhs', models.FloatField(null=True, blank=True)),
                ('t365_day_return_hhs', models.FloatField(null=True, blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'db_table': 'benchmarks',
            }