Django-oauth-toolkit: OAUTH2_PROVIDER_APPLICATION_MODEL default not loaded into settings

Created on 29 Apr 2015  路  14Comments  路  Source: jazzband/django-oauth-toolkit

I have a migration that depends on the application model being there - but since I'm not overriding the applicaiton model, I don't see the OAUTH2_PROVIDER_APPLICATION_MODEL in the settings.

Using django-configurations as well.

Most helpful comment

More recently, requires:

OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL = 'oauth2_provider.AccessToken'
OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application'
OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL = 'oauth2_provider.RefreshToken'

Pasting in case others encounter this open issue as I did.

All 14 comments

Hi yarbelk, did you ever find a solution to this issue? We're experiencing the same thing after migrating from django 1.5 to 1.7

Seeing this in Django 1.9 when running makemigrations. Not trying to use a custom model or anything, but one of my models has a foreign key to oauth2_provider.Application.

AttributeError: 'Settings' object has no attribute 'OAUTH2_PROVIDER_APPLICATION_MODEL'

Adding the setting fixes it, but it seems heavy-handed to fix it like that.

@jdp How do you fix the settings, I get the error right now , but no idea how to fix it.

@b35li copy the setting into your settings.py, like this:

OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application'

Closing as these versions of Django are no longer supported.

@jleclanche this is still happening with django 1.10.7, can you point me in the direction of what would need to be done to get a pr in for this?

Hi, as @jleclanche said this undocumented behaviour looks like is still there.

I'm running Django 1.11.5 and I think it's a problem of circular imports that I still didn't figure out. The issue is triggered by a deadly combo of these params I'm using in my tests:
-n: I've installed Django Test Without Migrations
-v 2: with verbose level set to 1 or 0, the issue does not show up.

Example of complete cmd line I'm using:
$ DJANGO_SETTINGS_MODULE=myprj.settings.test python manage.py test --noinput -n myprj.module.tests.test_class -v 2

My workaround is to set in my projects settings the two following constants:

OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL = 'oauth2_provider.AccessToken'                                                                         
OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application'                                                                          

More recently, requires:

OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL = 'oauth2_provider.AccessToken'
OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application'
OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL = 'oauth2_provider.RefreshToken'

Pasting in case others encounter this open issue as I did.

Still happening in Django 2.1

happen in django2.2 too

And happening in Django 3

django 2.2
python 3.7
i was having same the issue, i delete virtualenv folder re-install whole thing again. It worked!

I am having this exact problem... Any solution?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ashiksl picture ashiksl  路  3Comments

bryanveloso picture bryanveloso  路  6Comments

hackaprende picture hackaprende  路  5Comments

anveshagarwal picture anveshagarwal  路  6Comments

EmilTemirov picture EmilTemirov  路  5Comments