1👍
✅
The code in the doc is just a boilerplate, you need to implement value_to_string
to return a string representing the relativedelta
.
The RelativeDeltaField
is based on models.CharField
, thus the get_prep_value()
looks like
def get_prep_value(self, value):
return self.to_python(value)
It’s OK for CharField
because the intended value in Python of the field is already a string. However, your customized version of to_python()
returns relativedelta
instead of string.
👤okm
Source:stackexchange.com