我正在使用Django 2.x
和OAuth Toolkit
。
我正在编写一个应用程序,我需要在其中添加ForeignKey
指向插件Application
模型的指针OAuth Toolkit
,该模型定义为Abstract。
根据文档。我可以扩展AbstractApplication然后添加设置
OAUTH2_PROVIDER_APPLICATION_MODEL='your_app_name.MyApplication'
就我而言,我已经创建了我的应用程序和models.py
class CustomOAuthToolkitApplication(AbstractApplication):
pass
class OAuthToolkitTrackingLog(models.Model):
application_model = settings.OAUTH2_PROVIDER_APPLICATION_MODEL
application = models.ForeignKey(application_model, on_delete=models.CASCADE, blank=True, default=None, null=True)
user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True, default=None)
col_1 = models.CharField(max_length=255)
created = models.DateTimeField(auto_now_add=True)
并在settings.py
INSTALLED_APPS = [
...
'oauth2_provider',
'my_app',
]
OAUTH2_PROVIDER_APPLICATION_MODEL = 'my_app.CustomOAuthToolkitApplication'
但是当我运行命令生成迁移时
python manage.py makemigrations
它给出了错误
The field oauth2_provider.Grant.application was declared with a lazy reference to 'my_app.customoauthtoolkitapplication', but app 'my_app' isn't installed.
The field oauth2_provider.RefreshToken.application was declared with a lazy reference to 'my_app.customoauthtoolkitapplication', but app 'my_app' isn't installed.
我该如何解决这个问题?