2017-03-30 05:52:42 +08:00
|
|
|
from django.db.models import DateTimeField, Func, UUIDField
|
|
|
|
|
|
|
|
|
|
|
|
class RandomUUID(Func):
|
|
|
|
template = 'GEN_RANDOM_UUID()'
|
|
|
|
|
|
|
|
def __init__(self, output_field=None, **extra):
|
|
|
|
if output_field is None:
|
|
|
|
output_field = UUIDField()
|
|
|
|
super().__init__(output_field=output_field, **extra)
|
2015-06-02 01:00:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
class TransactionNow(Func):
|
|
|
|
template = 'CURRENT_TIMESTAMP'
|
|
|
|
|
|
|
|
def __init__(self, output_field=None, **extra):
|
|
|
|
if output_field is None:
|
|
|
|
output_field = DateTimeField()
|
2017-01-21 21:13:44 +08:00
|
|
|
super().__init__(output_field=output_field, **extra)
|