0

I am new with Django. I am using DRF. I was trying to integrate social authentication using dj-rest-framework and django-allauth, but I currently have an app called account, so it gives a naming conflict with allauth.account.

I managed to fix this by following this solution. It is a known problem with allauth.account and changing one of the apps label will fix the confilct.

Here comes the second problem. After I configured the URL, it gave an error

ProgrammingError
"Table '<project-name>.socialaccount_socialapp' doesn't exist"

So, I thought that maybe making migrations will fix the issue. When I try making migrations, it gave some different errors based on the changes that I made, but none of the solutions seems to work.

When I changed the label name of the AllAuth Account as described on the solution mentioned above and then trying to make the migrations python manage.py makemigrations gives this error:

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'

and then running: python manage.py makemigrations --merge gives

ValueError: Could not find common ancestor of ['0001_initial', '0002_email_max_length']

If I try changing my account app label instead of the allauth account label, some different errors occure.

django.db.migrations.exceptions.NodeNotFoundError: Migration myaccount.0004_auto_20210406_1505 dependencies reference nonexistent parent node ('account', '0003_something')

So the app name on the migration is still account instead of myaccount. Running python manage.py makemigrations gives the same error.

Manually modifying the migrations dependencies, so changing account to myaccount will fix this error, but then when trying to make the migrations again, a lot of other errors occure:

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'.
CurlyError
  • 305
  • 2
  • 15

1 Answers1

0

If your account app is already in the database then changing the app name requires more than that. You can follow the steps described in this question to do that: [1]: How to change the name of a Django app? If your project is still in development then you can clean all your migrations and database, rename your app and make a fresh start

  • I am not changing the app name, I'm only adding a label so it doesn't conflict. It is a feature that came with Django 1.7. The app is in use with multiple users and I don't really want to rename my account app. I want the simplest solution to fix the conflict and have everything working. – CurlyError Jul 30 '21 at 11:15
  • I saw the issues you were getting and because I wasn't comfortable with your approach. was quick to suggest something else. Maybe you can try to combine the two apps by removing your Account app from the installed applications and add app_label to each model to point to the allauth account app. But that may have side effects on your project that needs to be tested thoroughly. But again, having two distinct names is cleaner and safer and easier to maintain. – ZaherSarieddine Jul 30 '21 at 20:03