mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-04-18 18:30:58 +00:00
UUID model added
This commit is contained in:
parent
4e18710537
commit
38f8932e74
1 changed files with 18 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue