Add Django OAuth toolkit admin

This commit is contained in:
Alexandre Iooss 2020-09-21 12:15:40 +02:00
parent 6d54aae614
commit 72bac75fbd
3 changed files with 16 additions and 4 deletions

View File

@ -26,6 +26,14 @@ admin_site = StrongAdminSite()
admin_site.register(Site, SiteAdmin)
# Add external apps model
if "oauth2_provider" in settings.INSTALLED_APPS:
from oauth2_provider.admin import Application, ApplicationAdmin, Grant, \
GrantAdmin, AccessToken, AccessTokenAdmin, RefreshToken, RefreshTokenAdmin
admin_site.register(Application, ApplicationAdmin)
admin_site.register(Grant, GrantAdmin)
admin_site.register(AccessToken, AccessTokenAdmin)
admin_site.register(RefreshToken, RefreshTokenAdmin)
if "django_htcpcp_tea" in settings.INSTALLED_APPS:
from django_htcpcp_tea.admin import *
from django_htcpcp_tea.models import *

View File

@ -38,7 +38,9 @@ INSTALLED_APPS = [
'oauth2_provider',
# Django contrib
'django.contrib.admin',
# We do not import Django Admin directly to disable autodiscover.
# Autodiscover does not work with custom admin sites.
'django.contrib.admin.apps.SimpleAdminConfig',
'django.contrib.admindocs',
'django.contrib.auth',
'django.contrib.contenttypes',

View File

@ -32,9 +32,6 @@ urlpatterns = [
path('api/', include('api.urls')),
path('permission/', include('permission.urls')),
# OAuth2 provider
path('o/', include('oauth2_provider.urls', namespace='oauth2_provider')),
# Make coffee
path('coffee/', include('django_htcpcp_tea.urls')),
]
@ -43,6 +40,11 @@ urlpatterns = [
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
if "oauth2_provider" in settings.INSTALLED_APPS:
# OAuth2 provider
urlpatterns.append(
path('o/', include('oauth2_provider.urls', namespace='oauth2_provider'))
)
if "debug_toolbar" in settings.INSTALLED_APPS:
import debug_toolbar