import base64
from time import mktime
from datetime import datetime, date

from django.db.models import Q
from django.core.serializers.base import SerializationError

import simplejson as json


dt2ts = lambda obj: mktime(obj.timetuple()) if isinstance(obj, date) else obj


def get_model(model_name):
    try:
        from django.apps import apps
        return apps.get_model(model_name)
    except ImportError:
        from django.db.models.loading import get_model
        return get_model(model_name)