diff --git a/api_app/models.py b/api_app/models.py index d637d7968..4158d87f2 100644 --- a/api_app/models.py +++ b/api_app/models.py @@ -1794,12 +1794,6 @@ class SingletonModel(models.Model): Singleton is a desing pattern that allow only one istance of a class. """ - def save(self, *args, **kwargs): - # check required to delete the singleton instance and create a new one - if type(self).objects.count() == 0: - self.pk = 1 - super().save(*args, **kwargs) - class Meta: abstract = True constraints = [ @@ -1810,6 +1804,12 @@ class Meta: ), ] + def save(self, *args, **kwargs): + # check required to delete the singleton instance and create a new one + if type(self).objects.count() == 0: + self.pk = 1 + super().save(*args, **kwargs) + class LastElasticReportUpdate(SingletonModel): last_update_datetime = models.DateTimeField()