Added timestamp for model policy scheduling to the User class
[plstackapi.git] / planetstack / core / models / singletonmodel.py
1 from django.db import models
2
3 class SingletonModel(models.Model):
4     class Meta:
5         abstract = True
6  
7     def save(self, *args, **kwargs):
8         self.__class__.objects.exclude(id=self.id).delete()
9         super(SingletonModel, self).save(*args, **kwargs)
10  
11     @classmethod
12     def load(cls):
13         try:
14             return cls.objects.get()
15         except cls.DoesNotExist:
16             return cls()