Aah, I didn't think about updating the validators after calling
super().__init__, that's much nicer, thanks!
On Monday, 11 September 2017 12:02:10 UTC+1, Xavier Ordoquy wrote:
>
> Hi,
>
> DRF fields adds the validators during the init rather than setting them on
> Meta.
> That help with heritage
Hi,
DRF fields adds the validators during the init rather than setting them on Meta.
That help with heritage.
You can see how this works at
https://github.com/encode/django-rest-framework/blob/master/rest_framework/fields.py#L799-L802
Hope this helps,
Regards,
Xavier Ordoquy,
Linovia.
> Le 11
Hi all,
I'm trying to add a list of validators to a subclass of
rest_framework.fields.Field.
I would prefer to add the validators to the field declaration, rather than
every place it is used.
Ideally, I would like to be able to declare the Field similarly a
Serializer, e.g:
class MyField(rest