From cadd87c46cf5c14233655cdf910cfe39a7b15815 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 7 Mar 2018 09:56:48 +0100 Subject: Fix migration evaluation with virtualtime --- .../management/commands/makemigrations.py | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 ishtar_common/management/commands/makemigrations.py (limited to 'ishtar_common') diff --git a/ishtar_common/management/commands/makemigrations.py b/ishtar_common/management/commands/makemigrations.py new file mode 100644 index 000000000..15309b0d2 --- /dev/null +++ b/ishtar_common/management/commands/makemigrations.py @@ -0,0 +1,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 + -- cgit v1.2.3