Пример #1
0
    def get_field(self, doc, field):
        data = getattr(doc, field, '')
        # Attributes and method can be passed
        if isinstance(data, collections.Callable):
            data = data()

        # We want dd-mm-yyy format for exports whereas
        if type(data) == dt.date:
            data = data.strftime(FR_DATE_FORMAT)

        if type(data) == dt.datetime:
            data = data.strftime(FR_DATETIME_FORMAT)

        return stringify(data, none_val='')
Пример #2
0
    def get_field(self, doc, field):
        data = getattr(doc, field, '')
        # Attributes and method can be passed
        if isinstance(data, collections.Callable):
            data = data()

        # We want dd-mm-yyy format for exports whereas
        if type(data) == dt.date:
            data = data.strftime(FR_DATE_FORMAT)

        if type(data) == dt.datetime:
            data = data.strftime(FR_DATETIME_FORMAT)

        return stringify(data, none_val='')
Пример #3
0
 def get_field(self, doc, field):
     data = getattr(doc, field, '')
     return stringify(data, none_val='')