blob: 15309b0d234e1b93e733391c5ac5a14e54ed533b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
from datetime import datetime
from django.core.management.commands.makemigrations import Command
from django.db import models
original_deconstruct = models.Field.deconstruct
def new_deconstruct(self):
"""
virtualtime can induce bad signature for "now" function replace it
explicitly
"""
name, path, args, kwargs = original_deconstruct(self)
if 'default' in kwargs and callable(kwargs['default']) and \
kwargs['default'].__name__ == 'now':
kwargs['default'] = datetime.now
return name, path, args, kwargs
models.Field.deconstruct = new_deconstruct
|