diff options
Diffstat (limited to 'chimere/utils.py')
| -rw-r--r-- | chimere/utils.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/chimere/utils.py b/chimere/utils.py index f5bc44f..028da06 100644 --- a/chimere/utils.py +++ b/chimere/utils.py @@ -554,10 +554,11 @@ class CSVManager(ImportManager): return (new_item, updated_item, msg) @classmethod - def export(cls, queryset): + def export(cls, queryset, cols=[]): dct = {'description':unicode(datetime.date.today()), 'data':[]} cls_name = queryset.model.__name__.lower() - cols = list(cls.COLS) + if not cols: + cols = list(cls.COLS) for pm in queryset.model.all_properties(): cols.append((pm.name, pm.getAttrName(), pm.getAttrName()+'_set')) header = [col[0] for col in cols] @@ -568,7 +569,10 @@ class CSVManager(ImportManager): if callable(attr): data.append(attr(item)) else: - data.append(getattr(item, attr)) + v = getattr(item, attr) + if v == None: + v = '' + data.append(v) dct['data'].append(data) filename = unicode_normalize(settings.PROJECT_NAME + dct['description']\ + '.csv') |
