Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Application related objects contains swapped out instance #90

Closed
oliviersels opened this Issue Dec 20, 2013 · 2 comments

Comments

Projects
None yet
3 participants
@oliviersels
Copy link
Contributor

commented 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".

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.

oliviersels added a commit to oliviersels/django-oauth-toolkit that referenced this issue Dec 20, 2013

@masci

This comment has been minimized.

Copy link
Contributor

commented Dec 20, 2013

Thank you very much for spotting this out. I finally managed to process some old work so I'll be soon on your PR.

@masci masci closed this Mar 27, 2015

@thedrow

This comment has been minimized.

Copy link

commented Feb 11, 2016

This has regressed. See #347

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.