The problem with calling register_providers in ready() is that it reads from the database (to get all the AuthProviders), but ready is called during management commands, so it is not entirely safe to interact with the database at that time.
This PR refactors the function to take one provider model object and moves it from ready() to the view where the OAuth client object is needed. The register method on BaseOAuth looks safe to call multiple times and returns a client object.
When reviewing
You should see that the RuntimeWarning no longer occurs when starting up the app (or running any management command - e.g. makemigrations, makemessages).
Closes #2003
The problem with calling
register_providers
inready()
is that it reads from the database (to get all theAuthProvider
s), butready
is called during management commands, so it is not entirely safe to interact with the database at that time.This PR refactors the function to take one provider model object and moves it from
ready()
to the view where the OAuthclient
object is needed. Theregister
method onBaseOAuth
looks safe to call multiple times and returns a client object.When reviewing
You should see that the
RuntimeWarning
no longer occurs when starting up the app (or running any management command - e.g.makemigrations
,makemessages
).