resources.py 775 B

12345678910111213141516171819202122
  1. # -*- coding: utf-8 -*-
  2. from __future__ import absolute_import
  3. from import_export.fields import Field
  4. from import_export import resources
  5. from apps.foundation.models import Option
  6. class OptionResource(resources.ModelResource):
  7. def __init__(self):
  8. super(OptionResource, self).__init__()
  9. self.fields['name'] = Field(attribute='name')
  10. self.fields['type_text'] = Field(attribute='type_text')
  11. self.fields['enabled_text'] = Field(attribute='enabled_text')
  12. self.fields['notes'] = Field(attribute='notes')
  13. def get_export_headers(self):
  14. return [u'名称', u'类别', u'在用', u'备注',]
  15. class Meta:
  16. model = Option
  17. fields = ('name', 'type_text', 'enabled_text', 'notes',)
  18. export_order = fields