def save_stats_to_file(model):
 model_name = model._meta.model_name
 date = datetime.strptime(model.date, '%Y-%m-%d')
 path = u'{addon_id}/{date.year}/{date.month:02}/'.format(addon_id=model.addon_id, date=date)
 name_tpl = u'{date.year}_{date.month:02}_{date.day:02}_{model_name}.json'
 name = name_tpl.format(date=date, model_name=model_name)
 filepath = os.path.join(path, name)
 storage.save(filepath, ContentFile(serialize_stats(model)))

def save_stats_to_file ( model ) : model_name = model . _meta . model_name date = datetime . strptime ( model . date , '%Y-%m-%d' ) path = u'{addon_id}/{date.year}/{date.month:02}/' . format ( addon_id = model . addon_id , date = date ) name_tpl = u'{date.year}_{date.month:02}_{date.day:02}_{model_name}.json' name = name_tpl . format ( date = date , model_name = model_name ) filepath = os . path . join ( path , name ) storage . save ( filepath , ContentFile ( serialize_stats ( model ) ) )
save the given model to a file on the disc .