【发布时间】:2021-10-05 19:08:33
【问题描述】:
我是 Django 新手。我正在使用 DRF。我试图使用 dj-rest-framework 和 django-allauth 集成社交身份验证,但我目前有一个名为 account 的应用程序,因此它与 allauth.account 存在命名冲突。
我通过关注this solution 设法解决了这个问题。这是allauth.account 的一个已知问题,更改其中一个应用程序标签将解决冲突。
第二个问题来了。我配置了网址后,报错了
ProgrammingError
"Table '<project-name>.socialaccount_socialapp' doesn't exist"
所以,我认为进行迁移可能会解决问题。当我尝试进行迁移时,它根据我所做的更改给出了一些不同的错误,但似乎没有一个解决方案有效。
当我按照the solution mentioned above 中的描述更改 AllAuth 帐户的标签名称,然后尝试进行迁移 python manage.py makemigrations 时出现此错误:
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 帐户标签,则会出现一些不同的错误。
django.db.migrations.exceptions.NodeNotFoundError: Migration myaccount.0004_auto_20210406_1505 dependencies reference nonexistent parent node ('account', '0003_something')
所以迁移上的应用名称仍然是account,而不是myaccount。运行 python manage.py makemigrations 会出现同样的错误。
手动修改迁移依赖,因此将account更改为myaccount将修复此错误,但是当再次尝试进行迁移时,发生了很多其他错误:
ValueError: The field myaccount was declared with a lazy reference to 'account', but app 'account' doesn't provide model 'team'.
The field <app.something> was declared with a lazy reference to 'account', but app 'account' doesn't provide model 'team'.
The field <app.something> was declared with a lazy reference to 'account', but app 'account' doesn't provide model 'team'.
The field <app.something> was declared with a lazy reference to 'account', but app 'account' doesn't provide model 'team'.
The field <app.something> was declared with a lazy reference to 'account', but app 'account' doesn't provide model 'team'.
【问题讨论】:
标签: python django django-models django-rest-framework django-migrations