def csv_format(*models, headers=None):
    """
    Transforms an arbitrary list of models into a list of lists for easy export, ie to CSV.
    By default, will extract all headers from the given models' json, but specific headers can be given with
    the `headers` param as a list.
    """
    blobs = [model.json() for model in models]
    if not headers:
        # extract from models
        headers = []
        for blob in blobs:
            for key in blob:
                if key not in headers:
                    headers.append(key)

    res = [headers]
    for model in models:
        res.append([getattr(model, header, None) for header in headers])
    return res