19 lines
386 B
Python
19 lines
386 B
Python
from django.db.models import Model
|
|
|
|
|
|
class SingletonModel(Model):
|
|
class Meta:
|
|
abstract = True
|
|
|
|
def save(self, *args, **kwargs):
|
|
self.pk = 1
|
|
super(SingletonModel, self).save(*args, **kwargs)
|
|
|
|
def delete(self, *args, **kwargs):
|
|
pass
|
|
|
|
@classmethod
|
|
def load(cls):
|
|
obj, created = cls.objects.get_or_create(pk=1)
|
|
return obj
|