AttributeError:“ tuple”对象在开始迁移时没有属性“ startswith”

时间:2019-02-13 06:59:18

标签: python django django-models migration django-migrations

我进行了迁移,接下来我使用了迁移。 但这会导致下一个错误:AttributeError:'tuple'对象没有属性'startswith'

我知道,它与令人困惑的字符串和大量链接在一起,但是如何解决呢? Renterinfo.0001_initial何时开始迁移 这是我的renterinfo.0001_initial文件:

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Addresses',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('id_renter', models.IntegerField()),
                ('subject', models.IntegerField()),
                ('city', models.CharField(blank=True, max_length=50, null=True)),
                ('street', models.CharField(blank=True, max_length=50, null=True)),
                ('house', models.CharField(blank=True, max_length=4, null=True)),
                ('housing', models.CharField(blank=True, max_length=3, null=True)),
                ('building', models.CharField(blank=True, max_length=2, null=True)),
                ('office', models.CharField(blank=True, max_length=3, null=True)),
                ('telephon', models.CharField(blank=True, max_length=16, null=True)),
                ('type', models.TextField(blank=True, null=True)),
            ],
            options={
                'db_table': ('renterinfo_addresses',),
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='IndEntrep',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('org_prav_form', models.TextField()),
                ('inn', models.CharField(max_length=12)),
                ('account_name', models.CharField(max_length=20)),
                ('acc_pwd', models.CharField(blank=True, max_length=128, null=True)),
                ('second_name', models.CharField(max_length=40)),
                ('first_name', models.CharField(max_length=40)),
                ('patronymic', models.CharField(max_length=40)),
                ('identity_doc', models.CharField(max_length=40)),
                ('serial_doc', models.CharField(max_length=8)),
                ('number_doc', models.CharField(max_length=8)),
                ('ogrnip', models.CharField(blank=True, max_length=15, null=True)),
            ],
            options={
                'db_table': ('renterinfo_indentrep',),
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='LegalDocuments',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(blank=True, max_length=40, null=True)),
            ],
            options={
                'db_table': ('renterinfo_legaldocuments',),
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='Organizations',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('org_prav_form', models.TextField()),
                ('inn', models.CharField(max_length=12)),
                ('account_name', models.CharField(max_length=20)),
                ('acc_pwd', models.CharField(blank=True, max_length=128, null=True)),
                ('name', models.CharField(blank=True, max_length=50, null=True)),
                ('snameplp', models.CharField(blank=True, max_length=80, null=True)),
                ('fnameplp', models.CharField(blank=True, max_length=80, null=True)),
                ('patronymicplp', models.CharField(blank=True, max_length=80, null=True)),
                ('position', models.CharField(blank=True, max_length=80, null=True)),
                ('ogrn', models.CharField(blank=True, max_length=13, null=True)),
                ('identity_doc', models.CharField(blank=True, max_length=40, null=True)),
                ('serial_doc', models.CharField(blank=True, max_length=8, null=True)),
                ('number_doc', models.CharField(blank=True, max_length=8, null=True)),
                ('leg_docum', models.ForeignKey(blank=True, db_column='leg_docum', null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='renterinfo.LegalDocuments')),
            ],
            options={
                'db_table': ('renterinfo_organizations',),
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='Osnovanie',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(blank=True, max_length=100, null=True)),
            ],
            options={
                'db_table': ('renterinfo_osnovanie',),
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='Persons',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('org_prav_form', models.TextField()),
                ('inn', models.CharField(max_length=12)),
                ('account_name', models.CharField(max_length=20)),
                ('acc_pwd', models.CharField(blank=True, max_length=128, null=True)),
                ('second_name', models.CharField(max_length=40)),
                ('first_name', models.CharField(max_length=40)),
                ('patronymic', models.CharField(max_length=40)),
                ('identity_doc', models.CharField(max_length=40)),
                ('serial_doc', models.CharField(max_length=8)),
                ('number_doc', models.CharField(max_length=8)),
                ('ogrnip', models.CharField(blank=True, max_length=15, null=True)),
            ],
            options={
                'db_table': ('renterinfo_persons',),
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='Positions',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(blank=True, max_length=80, null=True)),
            ],
            options={
                'db_table': ('renterinfo_positions',),
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='Projects',
            fields=[
                ('id', models.BigAutoField(primary_key=True, serialize=False)),
                ('id_renter', models.BigIntegerField(blank=True, null=True)),
                ('num_proj', models.CharField(blank=True, max_length=80, null=True)),
                ('date_project', models.DateField(blank=True, null=True)),
                ('date_zakl', models.DateField(blank=True, null=True)),
            ],
            options={
                'db_table': ('renterinfo_projects',),
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='Renters',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('org_prav_form', models.TextField()),
                ('inn', models.CharField(max_length=12)),
                ('account_name', models.CharField(max_length=20, unique=True)),
                ('acc_pwd', models.CharField(blank=True, max_length=128, null=True)),
            ],
            options={
                'db_table': ('renterinfo_renters',),
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='Viddoc',
            fields=[
                ('id', models.IntegerField(primary_key=True, serialize=False)),
                ('type', models.TextField(blank=True, null=True)),
            ],
            options={
                'db_table': ('renterinfo_viddoc',),
                'managed': True,
            },
        ),
    ]

UPD models.py:

 from django.db import models


    class Addresses(models.Model): 
        id_renter = models.IntegerField()
        subject = models.IntegerField()
        city = models.CharField(max_length=50, blank=True, null=True)
        street = models.CharField(max_length=50, blank=True, null=True)
        house = models.CharField(max_length=4, blank=True, null=True)
        housing = models.CharField(max_length=3, blank=True, null=True)
        building = models.CharField(max_length=2, blank=True, null=True)
        office = models.CharField(max_length=3, blank=True, null=True)
        telephon = models.CharField(max_length=16, blank=True, null=True)
        type = models.TextField(blank=True, null=True)  # This field type is a guess.

        class Meta:
            managed = False
            db_table = 'renterinfo_addresses',
            managed = True

    class IndEntrep(models.Model):  
        id = models.AutoField(primary_key=True)
        org_prav_form = models.TextField()  # This field type is a guess.
        inn = models.CharField(max_length=12)
        account_name = models.CharField(max_length=20)
        acc_pwd = models.CharField(max_length=128, blank=True, null=True)
        second_name = models.CharField(max_length=40)
        first_name = models.CharField(max_length=40)
        patronymic = models.CharField(max_length=40)
        identity_doc = models.CharField(max_length=40)
        serial_doc = models.CharField(max_length=8)
        number_doc = models.CharField(max_length=8)
        ogrnip = models.CharField(max_length=15, blank=True, null=True)

        class Meta:
            managed = False
            db_table = 'renterinfo_indentrep',
            managed = True


    class LegalDocuments(models.Model):
        name = models.CharField(max_length=40, blank=True, null=True)

        class Meta:
            managed = False
            db_table = 'renterinfo_legaldocuments',
            managed = True




    class Organizations(models.Model): 
        id = models.AutoField(primary_key=True)
        org_prav_form = models.TextField()  # This field type is a guess.
        inn = models.CharField(max_length=12)
        account_name = models.CharField(max_length=20)
        acc_pwd = models.CharField(max_length=128, blank=True, null=True)
        name = models.CharField(max_length=50, blank=True, null=True)
        snameplp = models.CharField(max_length=80, blank=True, null=True)
        fnameplp = models.CharField(max_length=80, blank=True, null=True)
        patronymicplp = models.CharField(max_length=80, blank=True, null=True)
        position = models.CharField(max_length=80, blank=True, null=True)
        leg_docum = models.ForeignKey(LegalDocuments, models.DO_NOTHING, db_column='leg_docum', blank=True, null=True)
        ogrn = models.CharField(max_length=13, blank=True, null=True)
        identity_doc = models.CharField(max_length=40, blank=True, null=True)
        serial_doc = models.CharField(max_length=8, blank=True, null=True)
        number_doc = models.CharField(max_length=8, blank=True, null=True)

        class Meta:
            managed = False
            db_table = 'renterinfo_organizations',
            managed = True




    class Persons(models.Model):  
        id = models.AutoField(primary_key=True)
        org_prav_form = models.TextField()  # This field type is a guess.
        inn = models.CharField(max_length=12)
        account_name = models.CharField(max_length=20)
        acc_pwd = models.CharField(max_length=128, blank=True, null=True)
        second_name = models.CharField(max_length=40)
        first_name = models.CharField(max_length=40)
        patronymic = models.CharField(max_length=40)
        identity_doc = models.CharField(max_length=40)
        serial_doc = models.CharField(max_length=8)
        number_doc = models.CharField(max_length=8)
        ogrnip = models.CharField(max_length=15, blank=True, null=True)

        class Meta:
            managed = False
            db_table = 'renterinfo_persons',
            managed = True



    class Positions(models.Model):  
        name = models.CharField(max_length=80, blank=True, null=True)

        class Meta:
            managed = False
            db_table = 'renterinfo_positions',
            managed = True


    class Projects(models.Model): 
        id = models.BigAutoField(primary_key=True)
        id_renter = models.BigIntegerField(blank=True, null=True)
        num_proj = models.CharField(max_length=80, blank=True, null=True)
        date_project = models.DateField(blank=True, null=True)
        date_zakl = models.DateField(blank=True, null=True)

        class Meta:
            managed = False
            db_table = 'renterinfo_projects',
            managed = True



    class Renters(models.Model):
        org_prav_form = models.TextField()  # This field type is a guess.
        inn = models.CharField(max_length=12)
        account_name = models.CharField(unique=True, max_length=20)
        acc_pwd = models.CharField(max_length=128, blank=True, null=True)

        class Meta:
            managed = False
            db_table = 'renterinfo_renters',
            managed = True





    class Viddoc(models.Model): 
        id = models.IntegerField(primary_key=True)
        type = models.TextField(blank=True, null=True)

        class Meta:
            managed = False
            db_table = 'renterinfo_viddoc',
            managed = True


    class Osnovanie(models.Model): 
        name = models.CharField(max_length=100, blank=True, null=True)

        class Meta:
            managed = False
            db_table = 'renterinfo_osnovanie',
            managed = True


    # Create your models here.

1 个答案:

答案 0 :(得分:1)

您所有的db_table选项都以逗号结尾,将其转换为元组。删除那些逗号。

        db_table = 'renterinfo_addresses'

请注意,您将需要删除并重新创建该迁移。