Changes between Initial Version and Version 1 of Ticket #26819, comment 15
- Timestamp:
- Oct 23, 2016, 3:00:37 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #26819, comment 15
initial v1 1 1 This happens only for Inline admin models (only `validate_unique()` of `BaseModelFormSet` contains the problematic code). 2 2 3 This is not limited to `ArrayField`; any custom field may be affected. In our case, the `phonenumber_field.modelfields.PhoneNumberField` is causing the error `unhashable type: 'PhoneNumber'`. Since Django documentation does not mandate that custom fields are hashable (i.e., define the `__hash__()` method), I suppose that most of the existing non-builtin fields are affected.3 This is not related to the database and is purely a Python issue. This is not limited to `ArrayField`; any custom field may be affected. In our case, the `phonenumber_field.modelfields.PhoneNumberField` is causing the error `unhashable type: 'PhoneNumber'`. Since Django documentation does not mandate that custom fields are hashable (i.e., define the `__hash__()` method), I suppose that most of the existing non-builtin fields are affected. 4 4 5 5 Looks like the solution is either to keep `seen_data` as a `set()` and rely on some property of the field (unreliable and error-prone, see sample code below), or give up `set()` and manually implement removal of duplicates.