<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def invalidate_previous_tokens(sender, instance, **kwargs):
 """ Invalidates all previously issued tokens as a post_save signal. """

    active_tokens = None
    if isinstance(instance, CallbackToken):
        active_tokens = CallbackToken.objects.active().filter(user=instance.user).exclude(id=instance.id)

    # Invalidate tokens
    if active_tokens:
        for token in active_tokens:
            token.is_active = False
            token.save()