Fix KeyError raised when trying to sort application inventory by install count #458
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes an exception raised when trying to sort a machine group's application inventory by install count.
Changes:
IntegerColumn
.inventoryitem_set__count
(get_install_count
is still the column's processor).get_datatable
monkeypatch.get_datatable
monkeypatch now deletes the column when appropriate. Tested this manually withSHOW_INSTALL_COUNTS = False
- the 'Install Count' column is correctly not rendered & nothing in the table seems broken.To reproduce exception:
/inventory/machine/1/
(machine group 1's app inventory).Screen.Recording.2023-10-23.at.6.54.53.PM.mov
Datatables error 7 == server returned a 500. There's only one line in the root traceback:
But there's a further useful exception during handling:
I believe (not sure) this occurs because the 'install_count' column does not have a defined db source, but is not properly configured as a non-db sourced column. The column is misconfigured due to its idiosyncratic monkeypatch definition.
This causes django-datatable-view to attempt accessing field
None
on the Application model when asked to sort the column's data.