我正在使用 django-allauth,它的
account
应用程序与我的 account
应用程序冲突。
我通过基于此解决方案
为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 应用程序名称,使其不会与我的应用程序或迁移冲突?
您可以使用 django 重命名应用程序包包链接。我个人从未使用过它,但似乎不错。你可以尝试一下
您可以在 admin.py 中更新应用程序的详细名称,如下所示
from django.apps import apps
# https://docs.djangoproject.com/en/4.1/ref/applications/#for-application-authors
apps.get_app_config('auth').verbose_name = "Auth Management"
apps.get_app_config('admin_interface').verbose_name = "Admin Interface"