0
class_object = ModelClass(title=entity_object['title'], 
                            entities_definition_key=entity_object['entities_definition_key'],
                            orderId=entity_object['orderId'],uid = json.dumps( uuid.uuid4(), 
                            cls=UUIDEncoder))

ModelClass is mongoengine model class

json_output = class_object.serializing_method()
final_list.append(json_output)
another_class_object = AnotherModelClass(workflowId=body['workflowId'],entities_list=final_list)
another_class_object.save()

save() to mongodb

final_dict={}
final_dict['entities_list'] = another_class_object.entities_list
return HttpResponse(json.dumps({'entity_definition_dict':entity_definition_dict}))          

output-{'uid': "\"74b1900ccfbd44234563805ac0279d\""}

Anonymous
  • 55
  • 7

1 Answers1

0

I don't know why you need to call json.dumps() on the UUID. It causes all your problems and I can't imagine a problem it would fix.

class_object = ModelClass(
    ...,
    uid = uuid.uuid4().hex,
)
blueteeth
  • 3,330
  • 1
  • 13
  • 23