Skip to content

Django Lazy Reference ValueError after upgrading to the latest version and running migrations, #1120

Open
@smit-mehta25

Description

@smit-mehta25
    raise ValueError("\n".join(error.msg for error in errors))
ValueError: The field oauth2_provider.AccessToken.application was declared with a lazy reference to 'oauth.clientapplication', but app 'oauth' isn't installed.
The field oauth2_provider.AccessToken.source_refresh_token was declared with a lazy reference to 'oauth.clientrefreshtoken', but app 'oauth' isn't installed.
The field oauth2_provider.Grant.application was declared with a lazy reference to 'oauth.clientapplication', but app 'oauth' isn't installed.
The field oauth2_provider.RefreshToken.access_token was declared with a lazy reference to 'oauth.clientaccesstoken', but app 'oauth' isn't installed.
The field oauth2_provider.RefreshToken.application was declared with a lazy reference to 'oauth.clientapplication', but app 'oauth' isn't installed.

I am constantly facing this issues. Is there any solutions for this one,

oauth2_provider setting configurations:

OAUTH2_PROVIDER_APPLICATION_MODEL = "oauth.ClientApplication"
OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL = "oauth.ClientAccessToken"
OAUTH2_PROVIDER_GRANT_MODEL = "oauth.ClientGrant"
OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL = "oauth.ClientRefreshToken"
OAUTH2_PROVIDER_ID_TOKEN_MODEL = "oauth.ClientIdToken"
OAUTH2_PROVIDER = {
    "ACCESS_TOKEN_EXPIRE_SECONDS": 1800,
    "SCOPES": {
        "uid": "User ID read access",
    },
}

Even, I tried to apply run_before to my custom initial migrations. But No luck.

run_before = [
        ('oauth2_provider', '0001_initial'),
    ]

This is with Django==3.2.11 and django-oauth-toolkit==1.7.0

Below is the order of Apply migrations.

  Applying oauth.0001_initial_squashed_0004_auto_20220218_1009...accounts_ui client does not exist
accounts_ui client created
 OK
  Applying oauth2_provider.0001_initial... OK
  Applying oauth2_provider.0002_auto_20190406_1805... OK
  Applying oauth2_provider.0003_auto_20201211_1314... OK
  Applying oauth2_provider.0004_auto_20200902_2022... OK
  Applying oauth2_provider.0005_auto_20211222_2352... OK

But still i am facing the above error. I have tried everything that i could from other open issues. Such as ... Swappable models. Clean migrations, run before.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions