Я пытался расширить модель приложения Oauth2, используя эту ссылку .
Но при переносе возникли некоторые проблемы -
ValueError: Поле oauth2_provider.AccessToken.application было объявлено с ленивой ссылкой на «oauth2.companyfieldaddedapplication», но приложение «oauth2» не установлено.Поле oauth2_provider.Grant.application было объявлено с ленивой ссылкой на «oauth2.companyfieldaddedapplication», но приложение «oauth2» не установлено.Поле oauth2_provider.RefreshToken.application было объявлено с ленивой ссылкой на «oauth2.companyfieldaddedapplication», но приложение «oauth2» не установлено.
Я добавил oauth2 в instal_apps, но все равно выдает ошибку
Settings.py
installed_apps = [
'apps.oauth2',
]
OAUTH2_PROVIDER_APPLICATION_MODEL='oauth2.CompanyFieldAddedApplication'
Структура моего проекта
├── apollo_project
│ ├── __init__.py
│ ├── settings.py
│ ├── settings.py.ren
│ ├── urls.py
│ └── wsgi.py
├── apps
│ ├── oauth2
│ │ ├── admin.py
│ │ ├── apps.py
│ │ ├── __init__.py
│ │ ├── migrations
│ │ │ ├── 0001_initial.py
│ │ │ ├── 0002_auto_20190215_1402.py
│ │ │ └── __init__.py
│ │ ├── models.py
│ │ ├── tests.py
│ │ ├── urls.py
│ │ └── views.py
папка проекта> apps> oauth2> models.py
from django.db import models
from oauth2_provider.models import AbstractApplication
from apps.company.models import Company
class CompanyFieldAddedApplication(AbstractApplication):
company = models.ForeignKey(Company, on_delete=models.CASCADE, related_name='company')
Traceback
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/codism-7/.local/share/virtualenvs/apollo_django-njoxc1BQ/lib/python3.5/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/codism-7/.local/share/virtualenvs/apollo_django-njoxc1BQ/lib/python3.5/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/codism-7/.local/share/virtualenvs/apollo_django-njoxc1BQ/lib/python3.5/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/codism-7/.local/share/virtualenvs/apollo_django-njoxc1BQ/lib/python3.5/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/home/codism-7/.local/share/virtualenvs/apollo_django-njoxc1BQ/lib/python3.5/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/home/codism-7/.local/share/virtualenvs/apollo_django-njoxc1BQ/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 163, in handle
pre_migrate_apps = pre_migrate_state.apps
File "/home/codism-7/.local/share/virtualenvs/apollo_django-njoxc1BQ/lib/python3.5/site-packages/django/utils/functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/codism-7/.local/share/virtualenvs/apollo_django-njoxc1BQ/lib/python3.5/site-packages/django/db/migrations/state.py", line 210, in apps
return StateApps(self.real_apps, self.models)
File "/home/codism-7/.local/share/virtualenvs/apollo_django-njoxc1BQ/lib/python3.5/site-packages/django/db/migrations/state.py", line 278, in __init__
raise ValueError("\n".join(error.msg for error in errors))
ValueError: The field oauth2_provider.AccessToken.application was declared with a lazy reference to 'oauth2.companyfieldaddedapplication', but app 'oauth2' isn't installed.
The field oauth2_provider.Grant.application was declared with a lazy reference to 'oauth2.companyfieldaddedapplication', but app 'oauth2' isn't installed.
The field oauth2_provider.RefreshToken.application was declared with a lazy reference to 'oauth2.companyfieldaddedapplication', but app 'oauth2' isn't installed.