迁移后无法访问admin中的用户

时间:2022-01-22 21:37:55

So I successfully migrated from a profile model to an extended User model. The data migration all worked fine, but I can't access my users from the admin, I get the following error:

所以我成功地从配置文件模型迁移到扩展的用户模型。数据迁移工作正常,但我无法从管理员访问我的用户,我收到以下错误:

DatabaseError: (1146, "Table 'mydb.app_myuser_groups' doesn't exist")

All I have defined in models.py is the following:

我在models.py中定义的所有内容如下:

class MyUser(AbstractUser):
    isSpecial = models.BooleanField(default=True)

having followed these instructions. Is there more I need to do to get this to work?

遵循这些指示。我还需要做些什么才能让它发挥作用?

2 个解决方案

#1


1  

See my previous answer here and modify step 4 to look like this:

请在此处查看我之前的答案并修改第4步,如下所示:

# encoding: utf-8
from south.db import db
from south.v2 import SchemaMigration

class Migration(SchemaMigration):

    def forwards(self, orm):
        # Fill in the destination name with the table name of your model
        db.rename_table('auth_user', 'accounts_user')
        db.rename_table('auth_user_groups', 'accounts_user_groups')

    def backwards(self, orm):
        db.rename_table('accounts_user', 'auth_user')
        db.rename_table('accounts_user_groups', 'auth_user_groups')

    models = { ....... } # Leave this alone

#2


0  

AbstractUser inherits from PermissionMixin, which has a ManyToManyField to the Group model. So there should be a app_myuser_groups table in the database. South may be able to create the intermediate table, but I don't know how. What I know is that syncdbing after having removed app_myuser should work, even though your migration would be shredded.

AbstractUser继承自PermissionMixin,它具有到Group模型的ManyToManyField。所以数据库中应该有一个app_myuser_groups表。南方可能能够创建中间表,但我不知道如何。我所知道的是,删除app_myuser后的同步应该可以正常工作,即使您的迁移会被粉碎。

This question about adding a through table in a migration should give you more insight.

有关在迁移中添加直通表的问题应该可以为您提供更多信息。

#1


1  

See my previous answer here and modify step 4 to look like this:

请在此处查看我之前的答案并修改第4步,如下所示:

# encoding: utf-8
from south.db import db
from south.v2 import SchemaMigration

class Migration(SchemaMigration):

    def forwards(self, orm):
        # Fill in the destination name with the table name of your model
        db.rename_table('auth_user', 'accounts_user')
        db.rename_table('auth_user_groups', 'accounts_user_groups')

    def backwards(self, orm):
        db.rename_table('accounts_user', 'auth_user')
        db.rename_table('accounts_user_groups', 'auth_user_groups')

    models = { ....... } # Leave this alone

#2


0  

AbstractUser inherits from PermissionMixin, which has a ManyToManyField to the Group model. So there should be a app_myuser_groups table in the database. South may be able to create the intermediate table, but I don't know how. What I know is that syncdbing after having removed app_myuser should work, even though your migration would be shredded.

AbstractUser继承自PermissionMixin,它具有到Group模型的ManyToManyField。所以数据库中应该有一个app_myuser_groups表。南方可能能够创建中间表,但我不知道如何。我所知道的是,删除app_myuser后的同步应该可以正常工作,即使您的迁移会被粉碎。

This question about adding a through table in a migration should give you more insight.

有关在迁移中添加直通表的问题应该可以为您提供更多信息。