diff --git a/rest_framework_simplejwt/token_blacklist/models.py b/rest_framework_simplejwt/token_blacklist/models.py index e5058fd34..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, 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, on_delete=models.CASCADE) + token = models.OneToOneField( + OutstandingToken, related_name="blacklisted_token", on_delete=models.CASCADE + ) blacklisted_at = models.DateTimeField(auto_now_add=True)