serializing foreignkeys assumes value is serializable
|Reported by:||Alex Burgel||Owned by:||nobody|
|Cc:||Alex Burgel||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||yes|
in django.core.serializers.python, handle_fk_field and handle_m2m_field assume that the foreignkey value requires no conversion, i.e. value_to_string is not called. handle_fk_field sometimes does not even convert the foreignkey value to a string (line 58).
if you're using custom fields whose values are not serializable, then you're given no opportunity for conversion, and in the case of json, if that value isn't a native json type, then you get an exception.
the way to work around this is to write your own serializer or to use natural keys, but given that value_to_string exists, it should be used.