from django.contrib import admin
from .models import Authorization


@admin.register(Authorization)
class ApplicationAdmin(admin.ModelAdmin):
    pass

from django.contrib import admin
from .models import Authorization


@admin.register(Authorization)
class ApplicationAdmin(admin.ModelAdmin):

    def scope_list(self, app):
        return ', '.join(app.scopes)

    list_display = ['user', 'application', 'scope_list']

    list_select_related = ['user', 'application']

    readonly_fields = ['user']

    fields = ['user', 'application', 'scopes', 'code']

Improve Admin for Authorization objects
Improve Admin for Authorization objects

  from django.contrib import admin
  from .models import Authorization
  
  
  @admin.register(Authorization)
  class ApplicationAdmin(admin.ModelAdmin):
-     pass
  
+     def scope_list(self, app):
+         return ', '.join(app.scopes)
+ 
+     list_display = ['user', 'application', 'scope_list']
+ 
+     list_select_related = ['user', 'application']
+ 
+     readonly_fields = ['user']
+ 
+     fields = ['user', 'application', 'scopes', 'code']
+ 
Improve Admin for Authorization objects
## Code Before:
from django.contrib import admin
from .models import Authorization


@admin.register(Authorization)
class ApplicationAdmin(admin.ModelAdmin):
    pass

## Instruction:
Improve Admin for Authorization objects
## Code After:
from django.contrib import admin
from .models import Authorization


@admin.register(Authorization)
class ApplicationAdmin(admin.ModelAdmin):

    def scope_list(self, app):
        return ', '.join(app.scopes)

    list_display = ['user', 'application', 'scope_list']

    list_select_related = ['user', 'application']

    readonly_fields = ['user']

    fields = ['user', 'application', 'scopes', 'code']
