Describe the bug
Similar to #357, the yaml renderer is unable to serialize a MaxValueValidator.limit_value of type datetime.timedelta.
Using the JSON renderer solves the issue.
To Reproduce
Add a MaxValueValidator to a model field with a limit_value type of datetime.timedelta:
import datetime
from django.db import models
class MyModel(models.Model):
duration = models.DurationField(
default=datetime.timedelta(seconds=10),
validators=[
MaxValueValidator(
limit_value=datetime.timedelta(seconds=3600),
message='Limit message.',
),
],
)
Raised exception:
File "/usr/local/lib/python3.8/site-packages/yaml/representer.py", line 231, in represent_undefined
raise RepresenterError("cannot represent an object", data)
yaml.representer.RepresenterError: ('cannot represent an object', datetime.timedelta(seconds=3600))
Expected behavior
The yaml render should be able to serialize datetime.timedelta values.
Describe the bug
Similar to #357, the yaml renderer is unable to serialize a
MaxValueValidator.limit_valueof typedatetime.timedelta.Using the JSON renderer solves the issue.
To Reproduce
Add a
MaxValueValidatorto a model field with alimit_valuetype ofdatetime.timedelta:Raised exception:
Expected behavior
The yaml render should be able to serialize
datetime.timedeltavalues.