בסיס נתונים של סיסמאות ישנות בשפת פייתון

שלום.
אני מנסה להקים מערכת שתוכל לזכור סיסמאות ישנות ולבדוק האם הסיסמא זהה לשלושת הסיסמאות האחרונות שהיו בשימוש. במידה וכן לא תאפשר להחליף סיסמא.
הבעיה שכאשר מכניסים סיסמא זהה לסיסמא שכבר נמצאת ב-DB הוא לא מעדכן את זמן העדכון וגם לא מוסיף רשומה חדשה עם זמן העדכון.
ואז נוצר מצב שהוא לא באמת בודק מול השלוש הכי עדכניות.
אני מצרף כאן את הקוד :

class UniquePasswordsValidator(object):
    """
    Validate whether the password was once used by the user.

    The password is only checked for an existing user.
    """
    def __init__(self, HISTORY_PASSWORD_MEMORY=3):
        self.HISTORY_PASSWORD_MEMORY = HISTORY_PASSWORD_MEMORY


    def validate(self, password, user=None):

        if not user:
            return

        for user_config in UserPasswordHistoryConfig.objects.filter(user=user):
            password_hash = user_config.make_password_hash(password)
            for password_history_object in PasswordHistory.objects.filter(user_config=user_config).order_by("-date")[:self.HISTORY_PASSWORD_MEMORY]:
                if password_history_object.password == password_hash:
                    raise ValidationError(
                        _("You can not use a password that was being used in the past {} passwords in this application.".format(self.HISTORY_PASSWORD_MEMORY)),
                        code='password_used'
                    )
            pass