我刚刚将一个站点从Django -cms2.3.5迁移到2.4.1 (来自Stackoverflow的help )下的Django 1.4。
我现在正在升级到Django 1.5,这很难,因为我需要将旧的独立用户配置文件更新为新的自定义用户模型。我遵循了here的优秀说明,还用settings.AUTH_USER_MODEL替换了所有对User的引用。
不幸的是,Django-CMS的模型显然仍然引用User:当我输入manage.py runserver时,我得到这个错误:
CommandError: One or more models did not validate:
cms.pagemoderatorstate: 'user' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.
cms.globalpagepermission: 'user' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.
cms.pagepermission: 'user' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.
cms.pageuser: 'user_ptr' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.
cms.pageuser: 'created_by' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.
cms.pageusergroup: 'created_by' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.如何让Django-CMS使用新的用户模型?
谢谢!
发布于 2013-05-24 06:57:12
对于其他有这个问题的人,这里是我从https://github.com/divio/django-cms/issues/1798学到的总结。
有四种可能的选择:
在我的情况下,我会在短期内选择#3,在长期内选择#4。
发布于 2013-07-03 01:31:42
有一个非常简单的解决方案。只需在导入CMSPlugin之前注册您的自定义用户。示例:
从django.db导入模型从django.contrib.auth导入模型从django.contrib.auth.models导入模型作为auth_models从django.contrib.auth.models导入AbstractUser类用户(AbstractUser):电话= models.CharField(max_length=100)电子邮件= models.CharField(max_length=100) auth_models.User =用户从cms.models导入CMSPlugin
https://stackoverflow.com/questions/16601412
复制相似问题