mirror of
https://github.com/OpenBankProject/API-Manager.git
synced 2026-02-06 16:01:57 +00:00
17 lines
384 B
Python
17 lines
384 B
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
Base utilities
|
|
"""
|
|
|
|
from datetime import datetime
|
|
from django.contrib.humanize.templatetags.humanize import naturaltime
|
|
|
|
|
|
def json_serial(obj):
|
|
"""JSON serializer for objects not serializable by default json code"""
|
|
|
|
if isinstance(obj, datetime):
|
|
serial = naturaltime(obj)
|
|
return serial
|
|
raise TypeError('Type not serializable')
|