[damned-lies] Update custom field definitions and require Django 1.8



commit 6c1b8e459c30080b348cbea076726da0e0583449
Author: Claude Paroz <claude 2xlibre net>
Date:   Fri Oct 30 17:19:26 2015 +0100

    Update custom field definitions and require Django 1.8

 README           |    2 +-
 common/fields.py |   11 +++--------
 2 files changed, 4 insertions(+), 9 deletions(-)
---
diff --git a/README b/README
index 73758ae..b71f543 100644
--- a/README
+++ b/README
@@ -8,7 +8,7 @@ You can find the Data model in the /docs directory.
 Requirements
 ============
 
-1 - Django > 1.7.X
+1 - Django > 1.8.X
 
 2 - Python 2.7 (minimal)
     pillow (python-pillow) for hackergotchi checks.
diff --git a/common/fields.py b/common/fields.py
index f304dc3..80ba9bf 100644
--- a/common/fields.py
+++ b/common/fields.py
@@ -11,12 +11,10 @@ from django.db import models
 class DictionaryField(models.Field):
     description = "Dictionary object"
 
-    __metaclass__ = models.SubfieldBase
-
     def get_internal_type(self):
         return "TextField"
 
-    def to_python(self, value):
+    def from_db_value(self, value, *args):
         if value is None:
             return None
         elif value == "":
@@ -35,7 +33,7 @@ class DictionaryField(models.Field):
     def get_prep_value(self, value):
         if not value:
             return ""
-        elif isinstance(value, basestring):
+        if isinstance(value, basestring):
             return value
         else:
             return json.dumps(value)
@@ -60,10 +58,7 @@ class JSONField(models.TextField):
     """JSONField is a generic textfield that neatly serializes/unserializes
     JSON objects seamlessly"""
 
-    # Used so to_python() is called
-    __metaclass__ = models.SubfieldBase
-
-    def to_python(self, value):
+    def from_db_value(self, value, *args):
         """Convert our string value to JSON after we load it from the DB"""
 
         if value == "":


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]