【发布时间】:2021-07-30 13:07:55
【问题描述】:
我正在使用django-allauth,它的account 应用与我的account 应用冲突。
我通过基于this solution为 allauth.account 创建应用标签来解决此冲突
from django.apps import AppConfig
class AllAuthAccountConfig(AppConfig):
name = 'allauth.account'
label = 'allauth_account'
verbose_name = 'aullauth_account'
然后将其添加到已安装的应用中
INSTALLED_APPS = (
...,
'apps.allauth.apps.AllAuthAccountConfig',
...,
)
现在,当我尝试迁移时,它会报错
CommandError: Conflicting migrations detected; multiple leaf nodes in the migration graph: (0001_initial, 0002_email_max_length in allauth_account).
To fix them run 'python manage.py makemigrations --merge'
但python manage.py makemigrations --merge 也失败并出现以下错误:
ValueError: Could not find common ancestor of ['0001_initial', '0002_email_max_length']
如何更改 allauth.account 应用名称,使其不会与我的应用或迁移冲突?
【问题讨论】:
-
allauth.account具有以下("account", "0001_initial"),作为迁移0002_email_max_length中的依赖项,这意味着如果您更改其标签,它将中断,为什么不更改您的应用程序标签呢?它的迁移完全由您控制。见ticket #23790 -
@AbdulAzizBarkat 我试图更改我的应用程序标签,但这是一个大项目,它有一个正在使用的数据库。它给了我很多错误。你觉得有可能吗?
-
啊,在这种情况下,更改 allauth 似乎更简单和/或更容易。您可能只想制作自己的 allauth 自定义分支,然后使用它(编辑迁移文件)。如果您愿意,Replacing dependency with custom forks using pip 可能会帮助您做到这一点。
-
这可能是一个解决方案。我们也可以尝试一下,是的,如果您能提供帮助,我将不胜感激。
-
呃,我的意思是链接的问题会对你有所帮助。尽管您可以根据需要提出一些问题。无论如何,您需要为代码做的所有事情(希望如此)就是在迁移中更改
("account", "0001_initial"),行,对其进行分叉并配置您的要求,以便使用您的自定义分叉。
标签: python django django-models django-rest-framework django-apps