The conversion of some ToasterTable Build object querysets to JSON caused a serialisation error. This is because one of the fields in the queryset was of type decimal.Decimal, and our serialiser didn't know what to do with it.
Add a clause to check for decimal fields and serialise them so that correct JSON can be generated. Signed-off-by: Elliot Smith <[email protected]> --- bitbake/lib/toaster/toastergui/views.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index fbae36c..3e8a66b 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py @@ -43,6 +43,7 @@ from django.utils.html import escape from datetime import timedelta, datetime from django.utils import formats from toastergui.templatetags.projecttags import json as jsonfilter +from decimal import Decimal import json from os.path import dirname from functools import wraps @@ -145,6 +146,8 @@ def objtojson(obj): return obj.total_seconds() elif isinstance(obj, QuerySet) or isinstance(obj, set): return list(obj) + elif isinstance(obj, Decimal): + return str(obj) elif type(obj).__name__ == "RelatedManager": return [x.pk for x in obj.all()] elif hasattr( obj, '__dict__') and isinstance(obj, Model): -- Elliot Smith Software Engineer Intel OTC --------------------------------------------------------------------- Intel Corporation (UK) Limited Registered No. 1134945 (England) Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -- _______________________________________________ toaster mailing list [email protected] https://lists.yoctoproject.org/listinfo/toaster
