diff --git a/testproj/users/migrations/0002_setup_oauth2_apps.py b/testproj/users/migrations/0002_setup_oauth2_apps.py index 4fa5fe67..84024146 100644 --- a/testproj/users/migrations/0002_setup_oauth2_apps.py +++ b/testproj/users/migrations/0002_setup_oauth2_apps.py @@ -1,4 +1,5 @@ # Generated by Django 2.1.3 on 2018-12-19 07:57 +import pkg_resources from django.conf import settings from django.db import migrations @@ -27,10 +28,16 @@ def add_oauth_apps(apps, schema_editor): Application.objects.get_or_create(client_id=app['client_id'], defaults=app) +def get_oauth_dependency(): + oauth_version = pkg_resources.get_distribution('django-oauth-toolkit').version.split('.')[:2] + # 1.1 and 1.2 are before squasing migrations into 0001_initial + return '0006_auto_20171214_2232' if oauth_version in (('1', '1'), ('1', '2')) else '0001_initial' + + class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('oauth2_provider', '0006_auto_20171214_2232'), + ('oauth2_provider', get_oauth_dependency()), ('users', '0001_create_admin_user'), ]