now everything works fine - turned the Validation error raise to self.fail() call On Tuesday, August 16, 2022 at 9:42:42 AM UTC+2 Looping Ydobon wrote:
> but how to handle the issue then, how can correctly I validate timedelta > data for DurationField? > > On Monday, August 15, 2022 at 7:53:44 AM UTC+2 [email protected] wrote: > >> You don't raise exceptions at serializer. >> >> serializer.is_valid(raise_exception=Flase) >> >> >> >> Vào lúc 21:49:54 UTC+7 ngày Thứ Sáu, 12 tháng 8, 2022, Looping Ydobon đã >> viết: >> >>> Hello, >>> >>> DurationField does not cover cases when input value cannot be converted >>> to timestamp : >>> >>> timedelta(1000000000) # OverflowError: days=1000000000; must have >>> magnitude <= 999999999 >>> timedelta(100000000000) # OverflowError: Python int too large to >>> convert to C int >>> >>> Therefore I made a custom/inherited DuurationField class to cover those >>> cases and tried to raise a ValidationError inside to_internal_value(). >>> However, only err 500 is visible on GUI side :( >>> >>> Can someone give a hint on where this error is to be handled? >>> Enon >>> >> -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/7413034a-120c-447b-87ca-de0d66b92240n%40googlegroups.com.
