You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have been experiencing errors while trying to delete a user when a custom Application has been enabled. I have investigated the issue and found out that django mimics the db CASCADE delete behavior by manually trying to determine the objects it needs to delete. For this it uses the UserModel._meta.get_all_related_objects() call which will return the old Application model (oauth2_provider.Application). Django will then create a query trying to delete all applications for this user but this will use the non-existing db table "oauth2_provider_application".
DatabaseError: relation "oauth2_provider_application" does not exist
LINE 1: DELETE FROM "oauth2_provider_application" WHERE "oauth2_prov...
Django has solved this problem for its own custom user model by introducing a private api in the form of a Meta class argument: swappable. This takes the name of a setting which points to the newly swapped model (like AUTH_USER_MODEL).
The solution for django-oauth-toolkit would be to add swappable to the Application model but this means we need a new non-namespaced setting. Furthermore this will not work in 1.4 and I don't see any way to fix it for that version.
I have most of the code ready and tested and will open a pull request asap.
The text was updated successfully, but these errors were encountered:
oliviersels
added a commit
to oliviersels/django-oauth-toolkit
that referenced
this issue
Dec 20, 2013
We have been experiencing errors while trying to delete a user when a custom Application has been enabled. I have investigated the issue and found out that django mimics the db CASCADE delete behavior by manually trying to determine the objects it needs to delete. For this it uses the
UserModel._meta.get_all_related_objects()
call which will return the old Application model (oauth2_provider.Application). Django will then create a query trying to delete all applications for this user but this will use the non-existing db table "oauth2_provider_application".Django has solved this problem for its own custom user model by introducing a private api in the form of a Meta class argument: swappable. This takes the name of a setting which points to the newly swapped model (like AUTH_USER_MODEL).
The solution for django-oauth-toolkit would be to add swappable to the Application model but this means we need a new non-namespaced setting. Furthermore this will not work in 1.4 and I don't see any way to fix it for that version.
I have most of the code ready and tested and will open a pull request asap.
The text was updated successfully, but these errors were encountered: