Headless mode: User delete cascade looking for authenticator model despite not using mfa app
jboutros opened this issue · comments
I'm currently standing up a new django (5.0.5) project using the feat-headless branch in HEADLESS_ONLY
mode and a custom user model (and manager).
When I try to delete a user in the admin, I'm encountering this error:
ProgrammingError at /admin/users/user/1/delete/
relation "allauth_authenticator" does not exist
LINE 1: ...", "users_user"."name", "users_user"."email" FROM "allauth_a...
Strangely, I can delete the user object manually from the shell as follows with no issue:
>>> from users.models import User
>>> user_to_delete = User.objects.get(email="<redacted>")
>>> user_to_delete.delete()
(5, {'usersessions.UserSession': 2, 'account.EmailAddress': 1, 'socialaccount.SocialAccount': 1, 'users.User': 1})
I'm a little fuzzy on how this gets built but I'm noticing that the django.db.models.deletion.get_candidate_relations_to_delete
method is returning the authenticator model as a candidate model to cascade delete.
Here's an excerpt of my INSTALLED_APPS
...
"allauth",
"allauth.account",
"allauth.socialaccount",
"allauth.socialaccount.providers.google",
"allauth.headless",
"allauth.usersessions",
...
and my allauth settings:
ACCOUNT_AUTHENTICATION_METHOD = "email"
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_USER_MODEL_USERNAME_FIELD = None
ACCOUNT_CHANGE_EMAIL = True
ACCOUNT_EMAIL_VERIFICATION = "none"
SOCIALACCOUNT_EMAIL_AUTHENTICATION = True
SOCIALACCOUNT_EMAIL_AUTHENTICATION_AUTO_CONNECT = True
SOCIALACCOUNT_PROVIDERS = {
"google": {
...
}
}
# end django-allauth settings
AUTH_USER_MODEL = "users.User"
This was an issue in allauth -- fixed via f6baf33 -- can you try the updated branch?
Thanks @pennersr working as expected now!