请教:inspectdb之后System check identified some issues

来源:13-8 excel导入插件介绍

无无法师

2017-08-10


python manage.py inspectdb创建模型的时候除了数据库表模型自动还创建了下面的模型(没有贴完)。AuthGroup,AuthUserUserPermissions,AuthUserGroups......

class AuthGroup(models.Model):
    name = models.CharField(unique=True, max_length=80)

    class Meta:
        db_table = 'auth_group'


class AuthGroupPermissions(models.Model):
    group = models.ForeignKey(AuthGroup, models.DO_NOTHING)
    permission = models.ForeignKey('AuthPermission', models.DO_NOTHING)

    class Meta:
        db_table = 'auth_group_permissions'
        unique_together = (('group', 'permission'),)


class AuthPermission(models.Model):
    name = models.CharField(max_length=255)
    content_type = models.ForeignKey('DjangoContentType', models.DO_NOTHING)
    codename = models.CharField(max_length=100)

    class Meta:
        db_table = 'auth_permission'
        unique_together = (('content_type', 'codename'),)


class AuthUser(models.Model):
    password = models.CharField(max_length=128)
    last_login = models.DateTimeField(blank=True, null=True)
    is_superuser = models.IntegerField()
    username = models.CharField(unique=True, max_length=150)
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
    email = models.CharField(max_length=254)
    is_staff = models.IntegerField()
    is_active = models.IntegerField()
    date_joined = models.DateTimeField()

    class Meta:
        db_table = 'auth_user'


class AuthUserGroups(models.Model):
    user = models.ForeignKey(AuthUser, models.DO_NOTHING)
    group = models.ForeignKey(AuthGroup, models.DO_NOTHING)

    class Meta:
        db_table = 'auth_user_groups'
        unique_together = (('user', 'group'),)


class AuthUserUserPermissions(models.Model):
    user = models.ForeignKey(AuthUser, models.DO_NOTHING)
    permission = models.ForeignKey(AuthPermission, models.DO_NOTHING)

    class Meta:
        db_table = 'auth_user_user_permissions'
        unique_together = (('user', 'permission'),)


然后运行python manage.py makemigrations报错如下:

(firstM) C:\Users\wt271\mydesk>python manage.py migrations
SystemCheckError: System check identified some issues:
ERRORS:
auth.Group.permissions: (fields.E340) The field's intermediary table 'auth_group_permissions' clashes with the table name of 'desk1.AuthGro
upPermissions'.
auth.User.groups: (fields.E340) The field's intermediary table 'auth_user_groups' clashes with the table name of 'desk1.AuthUserGroups'.
auth.User.user_permissions: (fields.E340) The field's intermediary table 'auth_user_user_permissions' clashes with the table name of 'desk1
.AuthUserUserPermissions'.

http://szimg.mukewang.com/598c517b0001c2bb12550349.jpg

http://szimg.mukewang.com/598c7914000115d308350650.jpg

打开数据库发现这几张表已经建立好了,既然是Django自己创建的,为什么还会说有冲突?

使用--fake也不行

http://szimg.mukewang.com/598c7a560001eea813070627.jpg

尝试managed = True,继续error

删除数据库中原来创建的那6张表再测试,error


写回答

1回答

bobby

2017-08-11

这几张表不要删除 这是django默认的表, 你可以给我发个qq消息我给你看看

0
0

Python3.6+django+xadmin,打造在线教育平台

【毕设】Python 2.7到3.6 完美适配,Django升级2.0

3677 学习 · 4041 问题

查看课程