Don't create the bulk form if it's not needed
@@ -1468,6 +1468,8 @@ def __init__(self, *, columns: Namespace = None, _columns_dict=None, model=None,
input__attrs__class__all_pks=True,
)
+ # x.bulk.include can be a callable here. We treat that as truthy on purpose.
+ if any(x.bulk.include for x in declared_members(self).columns.values()) or 'actions' in self.bulk:
self.bulk_form = form_class(
_fields_dict=declared_bulk_fields,
_name='bulk',
@@ -1484,6 +1486,8 @@ def __init__(self, *, columns: Namespace = None, _columns_dict=None, model=None,
),
**bulk
)
+ else:
+ self.bulk_form = None
declared_members(self).bulk = self.bulk_form
@@ -1571,6 +1575,7 @@ def _setup_bulk_form_and_query(self):
if q:
self.rows = self.rows.filter(q)
+ if self.bulk_form is not None:
declared_fields = declared_members(self.bulk_form)['fields']
for name, column in declared_members(self)['columns'].items():
if name in declared_fields:
