1. Jannis Leidel
  2. south


Jannis Leidel  committed aee2b94

Handle cases better in which the default value of a field is set to the callable django.utils.timezone.now by setting it to datetime.datetime.now (to be able to be compatible to USE_TZ = False).

  • Participants
  • Parent commits 7933e67
  • Branches default

Comments (0)

Files changed (1)

File south/modelsinspector.py

View file
 NOISY = False
+    from django.utils import timezone
+except ImportError:
+    timezone = False
 # Gives information about how to introspect certain fields.
 # This is a list of triples; the first item is a list of fields it applies to,
 # (note that isinstance is used, so superclasses are perfectly valid here)
         # context (and because it changes all the time; people will file bugs otherwise).
         if value == datetime.datetime.now:
             return "datetime.datetime.now"
-        if value == datetime.datetime.utcnow:
+        elif value == datetime.datetime.utcnow:
             return "datetime.datetime.utcnow"
-        if value == datetime.date.today:
+        elif value == datetime.date.today:
             return "datetime.date.today"
+        # In case we use Django's own now function, revert to datetime's
+        # original one since we'll deal with timezones on our own.
+        elif timezone and value == timezone.now:
+            return "datetime.datetime.now"
         # All other callables get called.
         value = value()
     # Models get their own special repr()