I have a custom field with to_python and get_db_prep_value methods as defined below:
def to_python(self, value):
if not value:
return None
if isinstance(value, oauth2client.client.Credentials):
return value
return pickle.loads(base64.b64decode(value))
def get_db_prep_value(self, value, connection, prepared=False):
return base64.b64encode(pickle.dumps(value))
When I use dumpdata to dump this field, the values appear as:
"<oauth2client.client.OAuth2Credentials object at XXXXXXXX"
What should I do with the custom field in order to dump it and load it correctly?
Define a
value_to_stringmethod for the field. Relevent django docs.