1. Michael Elsdörfer
  2. djutils

Commits

Michael Elsdörfer  committed 18322a0

Make FuzzyDateField work with Django 1.2. Doesn't work without a to_python method anymore, and from reading the docs, get_prep_value seems to be the right method to implement now.

  • Participants
  • Parent commits beddfd5
  • Branches djutils

Comments (0)

Files changed (1)

File djutils/features/fuzzydate/fields.py

View file
         # as we are not using SubfieldBase (see intro), we need to do it's job
         # ourselfs. we don't need to be generic, so don't use a metaclass, but
         # just assign the descriptor object here.
-        setattr(cls, self.name, FuzzyDateCreator(self))
+        setattr(cls, self.name, FuzzyDateCreator(self))
+
+    def to_python(self, value):
+        # Parent implementation chokes on this
+        if isinstance(value, FuzzyDate):
+            return value
+        return super(FuzzyDateField, self).to_python(value)
 
-    def get_db_prep_save(self, value):
+    def get_prep_save(self, value):
         if isinstance(value, FuzzyDate): value = value.date
         return super(FuzzyDateField, self).get_db_prep_save(value)
 
             )],
         patterns = [
             re.escape("%s." % __name__)
-        ])
+        ])