@receiver(pre_save, sender=AccessToken)
def on_access_token_presave(sender, instance, *args, **kwargs):
 is_application_restricted = RestrictedApplication.objects.filter(application=instance.application).exists()
 if is_application_restricted:
  RestrictedApplication.set_access_token_as_expired(instance)

@ receiver ( pre_save , sender = AccessToken ) def on_access_token_presave ( sender , instance , * args , ** kwargs ) : is_application_restricted = RestrictedApplication . objects . filter ( application = instance . application ) . exists ( ) if is_application_restricted : RestrictedApplication . set_access_token_as_expired ( instance )
a hook on the accesstoken .