python - Adding a value to an Object retrieved via a QuerySet -
in django call objects via querysets , put them in dict give them template.
objectinstance = object.objects.get(pk=pk) objectsinstancedict = {'value1': objectinstance.value1, 'value2': objectinstance.value2, 'specialvalue': somebusinesslogic(data_to_aggregate) sometimes specialvalue timestamp converted string other times there analysis done data.
instead of creating dict add special value objectinstance instead don't have repeat existing values , adding new computed values.
how this?
and please tell me if made fundamental mistake work around here.
django model instances normal python objects. other python object, can freely add attributes them @ time.
object_instance = object.objects.get(pk=pk) object_instance.special_value = somebusinesslogic(data_to_aggregate)
Comments
Post a Comment