From d7c072a35cf96290756bb6d979f92358e9a7333d Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Sun, 26 Jan 2025 20:52:47 -0300 Subject: [PATCH] fix(currencies): don't error out if from_currency or to_currency isn't set --- app/apps/currencies/models.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/apps/currencies/models.py b/app/apps/currencies/models.py index 536185a..e840843 100644 --- a/app/apps/currencies/models.py +++ b/app/apps/currencies/models.py @@ -72,7 +72,9 @@ class ExchangeRate(models.Model): def clean(self): super().clean() - if self.from_currency == self.to_currency: - raise ValidationError( - {"to_currency": _("From and To currencies cannot be the same.")} - ) + # Check if the attributes exist before comparing them + if hasattr(self, "from_currency") and hasattr(self, "to_currency"): + if self.from_currency == self.to_currency: + raise ValidationError( + {"to_currency": _("From and To currencies cannot be the same.")} + )