Skip to content

OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL Circular Dependency #487

@renderbox

Description

@renderbox

When trying to run migrations where we define OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL as a custom model, it fails consistently.

./manage.py migrate

results in:

`ValueError: Related model 'shared.OrbitalAccessToken' cannot be resolved

Commenting out OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL let's me apply all the migrations but this solution creates an unworkable solution for automatic deployments.

If after all the tables that are expected are generated and I want to run > ./manage.py migrate to make sure (I expect it to say all migrations are applied already), I get this error:

ValueError: The field oauth2_provider.RefreshToken.access_token was declared with a lazy reference to 'shared.accesstoken', but app 'shared' doesn't provide model 'accesstoken'.

I even tried wiping out my DB table & all my migrations just to see what would happen and in that case I get this error:

django.db.migrations.exceptions.CircularDependencyError: oauth2_provider.0001_initial, shared.0001_initial

Also tried setting the 'run_before' value:

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

but because of the dependency on migrations.swappable_dependency(settings.OAUTH2_PROVIDER_APPLICATION_MODEL) it fails.

This is with Django 1.10.7, Python 3.6.0 & Postgres 9.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions