Removing a SourceColumn
Removing a SourceColumn
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.
---
LeVon Smoker
LeVon Smoker
Re: Removing a SourceColumn
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
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.
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
)
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)