Skip to content

Commit a83f19a

Browse files
committed
Make Application model truly 'swappable'
This also introduces a new non-namespaced setting OAUTH2_PROVIDER_APPLICATION_MODEL.
1 parent 2f3fc6e commit a83f19a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

oauth2_provider/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ def __str__(self):
109109
class Application(AbstractApplication):
110110
pass
111111

112+
# Add swappable like this to not break django 1.4 compatibility
113+
Application._meta.swappable = 'OAUTH2_PROVIDER_APPLICATION_MODEL'
114+
112115

113116
@python_2_unicode_compatible
114117
class Grant(models.Model):

oauth2_provider/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
'WRITE_SCOPE': 'write',
3535
'AUTHORIZATION_CODE_EXPIRE_SECONDS': 60,
3636
'ACCESS_TOKEN_EXPIRE_SECONDS': 36000,
37-
'APPLICATION_MODEL': 'oauth2_provider.Application',
37+
'APPLICATION_MODEL': getattr(settings, 'OAUTH2_PROVIDER_APPLICATION_MODEL', 'oauth2_provider.Application'),
3838

3939
# Special settings that will be evaluated at runtime
4040
'_SCOPES': [],

0 commit comments

Comments
 (0)