Skip to content

Commit

Permalink
Add list_select_related for performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdirahimi1999 committed May 25, 2024
1 parent 3b71b89 commit 7e3a177
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions rest_framework_simplejwt/token_blacklist/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@ class OutstandingTokenAdmin(admin.ModelAdmin):
"user__id",
"jti",
)
list_select_related = ("user", )
ordering = ("user",)

def get_queryset(self, *args, **kwargs) -> QuerySet:
qs = super().get_queryset(*args, **kwargs)

return qs.select_related("user")

# Read-only behavior defined below
actions = None

Expand Down Expand Up @@ -66,13 +62,9 @@ class BlacklistedTokenAdmin(admin.ModelAdmin):
"token__user__id",
"token__jti",
)
list_select_related = ("token__user",)
ordering = ("token__user",)

def get_queryset(self, *args, **kwargs) -> QuerySet:
qs = super().get_queryset(*args, **kwargs)

return qs.select_related("token__user")

def token_jti(self, obj: BlacklistedToken) -> str:
return obj.token.jti

Expand Down

0 comments on commit 7e3a177

Please sign in to comment.