Guard against rename_fields=None in submitted comprehension

The `submitted` list comprehension previously called `f in self.rename_fields`
which raises TypeError when a subclass sets rename_fields=None. Short-circuit
with `self.rename_fields and` to safely handle None, empty tuple, and populated
tuples uniformly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Brian Tiemann 2026-05-21 05:54:48 -04:00 committed by Jeremy Stretch
parent 9e909a9267
commit a3b50b4198
1 changed files with 1 additions and 1 deletions

View File

@ -962,7 +962,7 @@ class BulkRenameView(GetReturnURLMixin, BaseMultiObjectView):
if form.is_valid():
submitted = [
f for f in request.POST.getlist('field_names')
if f in self.rename_fields
if self.rename_fields and f in self.rename_fields
]
if self.rename_fields and not submitted:
form.add_error(None, _("Select at least one field to rename."))