diff --git a/core/models/local.py b/core/models/local.py index e48891c..2efb4e2 100644 --- a/core/models/local.py +++ b/core/models/local.py @@ -17,7 +17,13 @@ class Currency(Model): @classmethod def get_base(cls): - return cls.objects.get(base=True) + try: + return cls.objects.get(base=True) + except cls.DoesNotExist: + try: + return cls.objects.first() + except cls.DoesNotExist: + return cls.objects.create(name="Euro", code="EUR", symbol="€", base=True) def __str__(self): return f"{self.name} ({self.code})" @@ -42,4 +48,4 @@ class TaxRule(Model): reverse_charge = BooleanField(default=False) def __str__(self): - return str(self.destination_country) \ No newline at end of file + return str(self.destination_country)