Sunday, May 09, 2021

Get Json of Django Object

I found unnecessarily difficult to get json from django model object. Here is my simple solution to get that done.
def get_json_object(obj, fields): return {f:obj.__dict__[f] for f in fields}

No comments:

Turkce-Ingilizce Tekerleme

I scream, you scream we all scream for ice scream I run, you run we all run for ayran