Changes between Initial Version and Version 1 of Ticket #26819, comment 15


Ignore:
Timestamp:
Oct 23, 2016, 3:00:37 PM (8 years ago)
Author:
Meiyer

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #26819, comment 15

    initial v1  
    11This happens only for Inline admin models (only `validate_unique()` of `BaseModelFormSet` contains the problematic code).
    22
    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.
     3This 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.
    44
    55Looks 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.
Back to Top