You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Model cluster does not support primary keys that are not of simple types.
If you have a primary key that uses something like this CashField from django's tests that doesn't inherit from one of the basic types known to the DjangoJSONEncoder then you get <Foo object at ...> is not JSON serializable.
The Cash object I linked to inherits from decimal.Decimal but that is because it is only a simple example for testing.
I just submitted a pull request. All tests pass for me locally. This issue isn't just for primary keys. That is just what I ran into first. It would be for any field that returns a value that cannot be directly converted to json. Not sure how you would want to test it. I can put together a quick test if you want with a custom field like the CashField in the django tests if you like
Model cluster does not support primary keys that are not of simple types.
If you have a primary key that uses something like this CashField from django's tests that doesn't inherit from one of the basic types known to the DjangoJSONEncoder then you get <Foo object at ...> is not JSON serializable.
The Cash object I linked to inherits from decimal.Decimal but that is because it is only a simple example for testing.
ModelCluster needs to do some sort of is_serializable check at https://github.com/torchbox/django-modelcluster/blob/c72110e7789415196336584c70b2706fe74dbc2d/modelcluster/models.py#L44 and use Field.value_to_string or the like if the object isn't serializable
The text was updated successfully, but these errors were encountered: