Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # /lib/app/application.py
- def to_json(self, v):
- """
- Convert custom types to json string
- :param v:
- :return:
- """
- if v is None:
- return None
- elif isinstance(v, datetime.datetime):
- if hasattr(self.TZ, 'localize'):
- return self.TZ.localize(v).isoformat()
- else:
- return v.replace(tzinfo=self.TZ).isoformat()
- else:
- raise Exception("Invalid to_json type")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement