Created
May 3, 2015 09:37
-
-
Save theskumar/11ef947c44e252127923 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import absolute_import, unicode_literals | |
# Standard Library | |
import uuid | |
# Third Party Stuff | |
from django.db import models | |
from django_extensions.db.models import TimeStampedModel | |
class UUIDModel(models.Model): | |
''' | |
An abstract base class model that makes primary key `id` as UUID | |
instead of default auto incremented number. | |
''' | |
id = models.UUIDField(primary_key=True, editable=False, default=uuid.uuid4) | |
class Meta: | |
abstract = True | |
class TimeStampedUUIDModel(TimeStampedModel, UUIDModel): | |
''' | |
An abstract base class model that provides self-updating | |
``created`` and ``modified`` fields with UUID as primary_key field. | |
''' | |
class Meta: | |
abstract = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment