Page 1 of 1
Removing a SourceColumn
Posted: Thu Jul 21, 2022 7:24 pm
by lsmoker
Is there a way to remove SourceColumns? I've added some, but I'd also like to remove mimetype and encoding from the DocumentFile view.
Re: Removing a SourceColumn
Posted: Mon Aug 01, 2022 2:51 am
by michael
That functionality is being added to the navigation classes but its not documented and not complete. Eventually all SourceColumn instances will have a 'name' attribute to be able to reference them independently and removed.
Example from events/apps.py
Code: Select all
SourceColumn(
attribute='timestamp', is_identifier=True,
is_sortable=True, label=_('Date and time'), name='timestamp',
source=Action
)
For now what we do in some custom apps is iterate over the SourceColumns of a source object, match the attribute and remove that SourceColumn from the list of source object columns.
This example removes the creation date and time columns from the recently created document proxy model.
Code: Select all
source_columns = SourceColumn._registry.get(RecentlyCreatedDocument, ())
for source_column in source_columns:
if source_column.attribute == 'datetime_created':
source_columns.remove(source_column)
Re: Removing a SourceColumn
Posted: Mon Aug 01, 2022 12:48 pm
by lsmoker
Thanks for this!