I have an application where we've upgraded from Django 1.7 to 1.9 that makes extensive use of the new Postgres JSONField type. Now that JSONField is native to Django I'm trying to get it to work with our existing code base. We have a class that won't automatically serialize to json so I've extended the JSONField class with a new JSONSerializedField which basically attempts to call to_json() and from_json() methods on objects if it can.
-- Here's the code: https://bpaste.net/show/52e05f5ae2a9
By overloading get_prep_value() I've been able to handle the python->json conversion. I'm having trouble figuring out what I need to overload to handle the json->python conversion, however. Overloading to_python() doesn't seem to work as my method is never called. How can I achieve what my to_python method is trying to accomplish with the new JSONField?
thanx,
-- Ben Scherrey
--
Chief Systems Architect Proteus Technologies
This email intended solely for those who have received it. If you have received this email by accident - well lucky you!!
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHN%3D9D6gPzZ%2BuyCR6Jt3RjRnivFFwTO1OH4DyMMHC_XZfW1oCA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment