@classmethod
def obj_to_dict(cls, obj):
    """
        Takes a model object and converts it into a dictionary suitable for
        passing to the constructor's data attribute.
        """
    data = {}
    for field_name in cls.get_fields():
        try:
            value = getattr(obj, field_name)
        except AttributeError:
            continue
        if callable(value):
            value = value()
        data[field_name] = value
    return data
