Exclude some common fields from django-import-export (#5349)

- Add "get_fields()" method to InvenTreeResource
- Override default behaviour and exclude some common fields
- Will flow down to any inheriting classes
This commit is contained in:
Oliver 2023-07-26 16:54:02 +10:00 committed by GitHub
parent 6660508326
commit 941451203a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,3 +31,15 @@ class InvenTreeResource(ModelResource):
row[idx] = val
return row
def get_fields(self, **kwargs):
"""Return fields, with some common exclusions"""
fields = super().get_fields(**kwargs)
fields_to_exclude = [
'metadata',
'lft', 'rght', 'tree_id', 'level',
]
return [f for f in fields if f.column_name not in fields_to_exclude]