From 4c3c82d3780569486ed5497db81af9bf5c7a1494 Mon Sep 17 00:00:00 2001 From: Joris Jansen Date: Thu, 29 Jun 2023 09:02:10 +0200 Subject: [PATCH 1/2] Added related_name to both OutstandingToken as well as BlacklistedToken --- rest_framework_simplejwt/token_blacklist/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rest_framework_simplejwt/token_blacklist/models.py b/rest_framework_simplejwt/token_blacklist/models.py index e5058fd34..253118936 100644 --- a/rest_framework_simplejwt/token_blacklist/models.py +++ b/rest_framework_simplejwt/token_blacklist/models.py @@ -5,7 +5,7 @@ class OutstandingToken(models.Model): id = models.BigAutoField(primary_key=True, serialize=False) user = models.ForeignKey( - settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True, blank=True + settings.AUTH_USER_MODEL, related_name="outstanding_tokens", on_delete=models.SET_NULL, null=True, blank=True ) jti = models.CharField(unique=True, max_length=255) @@ -34,7 +34,7 @@ def __str__(self) -> str: class BlacklistedToken(models.Model): id = models.BigAutoField(primary_key=True, serialize=False) - token = models.OneToOneField(OutstandingToken, on_delete=models.CASCADE) + token = models.OneToOneField(OutstandingToken, related_name="blacklisted_token", on_delete=models.CASCADE) blacklisted_at = models.DateTimeField(auto_now_add=True) From 591cac6ddcca6bc2b2d399d8c5d604037b47f2c9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 29 Jun 2023 07:07:03 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- rest_framework_simplejwt/token_blacklist/models.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rest_framework_simplejwt/token_blacklist/models.py b/rest_framework_simplejwt/token_blacklist/models.py index 253118936..b7d542bc7 100644 --- a/rest_framework_simplejwt/token_blacklist/models.py +++ b/rest_framework_simplejwt/token_blacklist/models.py @@ -5,7 +5,11 @@ class OutstandingToken(models.Model): id = models.BigAutoField(primary_key=True, serialize=False) user = models.ForeignKey( - settings.AUTH_USER_MODEL, related_name="outstanding_tokens", on_delete=models.SET_NULL, null=True, blank=True + settings.AUTH_USER_MODEL, + related_name="outstanding_tokens", + on_delete=models.SET_NULL, + null=True, + blank=True, ) jti = models.CharField(unique=True, max_length=255) @@ -34,7 +38,9 @@ def __str__(self) -> str: class BlacklistedToken(models.Model): id = models.BigAutoField(primary_key=True, serialize=False) - token = models.OneToOneField(OutstandingToken, related_name="blacklisted_token", on_delete=models.CASCADE) + token = models.OneToOneField( + OutstandingToken, related_name="blacklisted_token", on_delete=models.CASCADE + ) blacklisted_at = models.DateTimeField(auto_now_add=True)