diff --git a/apps/accounts/models/account.py b/apps/accounts/models/account.py index c6da60d48..0f4077536 100644 --- a/apps/accounts/models/account.py +++ b/apps/accounts/models/account.py @@ -155,9 +155,6 @@ class AccountTemplate(BaseAccount): ).first() return account - def __str__(self): - return self.username - @staticmethod def bulk_update_accounts(accounts, data): history_model = Account.history.model diff --git a/apps/accounts/models/mixins/vault.py b/apps/accounts/models/mixins/vault.py index a551f20aa..e517516a9 100644 --- a/apps/accounts/models/mixins/vault.py +++ b/apps/accounts/models/mixins/vault.py @@ -85,4 +85,8 @@ class VaultModelMixin(models.Model): def save(self, *args, **kwargs): """ 通过 post_save signal 处理 _secret 数据 """ + update_fields = kwargs.get('update_fields') + if update_fields and 'secret' in update_fields: + update_fields.remove('secret') + update_fields.append('_secret') return super().save(*args, **kwargs)