UUID model added

This commit is contained in:
JMP 2019-02-26 17:32:56 +01:00
parent 4e18710537
commit 38f8932e74

View file

@ -1,5 +1,8 @@
from __future__ import unicode_literals
from model_utils.managers import QueryManager, SoftDeletableManager
from model_utils.fields import AutoCreatedField, AutoLastModifiedField, StatusField, MonitorField, UUIDField
import django
from django.core.exceptions import ImproperlyConfigured
from django.db import models
@ -10,10 +13,6 @@ if django.VERSION >= (1, 9, 0):
else:
from django.utils.timezone import now
from model_utils.managers import QueryManager, SoftDeletableManager
from model_utils.fields import AutoCreatedField, AutoLastModifiedField, \
StatusField, MonitorField
class TimeStampedModel(models.Model):
"""
@ -135,3 +134,18 @@ class SoftDeletableModel(models.Model):
self.save(using=using)
else:
return super(SoftDeletableModel, self).delete(using=using, *args, **kwargs)
class UUIDModel(models.Model):
"""
This abstract base class provides id field on any model that inherits from it
which will be the primary key.
"""
id = UUIDField(
primary_key=True,
version=4,
editable=False,
)
class Meta:
abstract = True