I understand that you can go about solving it this way, but it seems like a 
lot of extra work when it just works the way you would expect on a Django 
ModelForm. I'm guessing this isn't possible for it to "just work", so I 
might end up making an issue in the DRF project.

On Saturday, June 27, 2020 at 3:34:05 PM UTC-5, Carl Nobile wrote:
>
> Then write your custom validation as a field validator and put them all in 
> the list in the order you want them to fire off in or you could include the 
> field validator checks into your custom validation method.
> The problem is that DRF can only implement what the common cases are, not 
> all the edge cases people may need, but the hooks are there in the code to 
> customize it the way you want.
>
>
> On Sat, Jun 27, 2020 at 4:05 PM Brent O'Connor <br...@epicserve.com 
> <javascript:>> wrote:
>
>> Unfortunately, that doesn't really solve the issue because you want 
>> field-level validation to run because you want to make sure that valid 
>> numbers, etc. are being sent to the API.
>>
>> On Sat, Jun 27, 2020 at 12:25 PM Carl Nobile <carl....@gmail.com 
>> <javascript:>> wrote:
>>
>>> It is possible to turn off the built infield errors. The empty list 
>>> essentially turns off al field validation. If there are multiple and you 
>>> don't want all turned off you would need to specify them yourself.
>>>
>>> Class SomeSeializer(...):
>>>
>>>     class Meta:
>>>         extra_kwargs = { 
>>>            'field_name': {'validators': []}, 
>>>            }
>>>
>>> On Fri, Jun 26, 2020 at 6:08 PM Brent O'Connor <epic...@gmail.com 
>>> <javascript:>> wrote:
>>>
>>>> I created an example project 
>>>> <https://github.com/epicserve/drf-validation-issue> to illustrate this 
>>>> issue, but basically if you have custom validation logic on a serializer 
>>>> and the data has a field that isn't valid, then the errors raised are only 
>>>> the field level errors and not the custom validation logic errors. This 
>>>> ends up being a bad user experience because the user can fix the field 
>>>> error and then when post another request they can end up getting errors 
>>>> thrown in the custom validation. I'm thinking this might need to be an 
>>>> issue added the DRF project on Github, but thought I would check here 
>>>> first. Please see the project example for more details.
>>>>
>>>> -- 
>>>> 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 django-rest-framework+unsubscr...@googlegroups.com 
>>>> <javascript:>.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/django-rest-framework/121a7ebe-4b34-4197-be60-1178730361f7o%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/django-rest-framework/121a7ebe-4b34-4197-be60-1178730361f7o%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>
>>>
>>> -- 
>>>
>>> -------------------------------------------------------------------------------
>>> Carl J. Nobile (Software Engineer)
>>> carl....@gmail.com <javascript:>
>>>
>>> -------------------------------------------------------------------------------
>>>
>>> -- 
>>> 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 django-rest-framework+unsubscr...@googlegroups.com 
>>> <javascript:>.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-rest-framework/CAGQqDQ%2BOzPQ-Xuad4OboE-%2BgXF_-uAkuxF%2B9XT5jLPiAnFJfog%40mail.gmail.com
>>>  
>>> <https://groups.google.com/d/msgid/django-rest-framework/CAGQqDQ%2BOzPQ-Xuad4OboE-%2BgXF_-uAkuxF%2B9XT5jLPiAnFJfog%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> -- 
>> 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 django-rest-framework+unsubscr...@googlegroups.com <javascript:>
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-rest-framework/CA%2Bx7ZMq7iMmi4PaQ9aBjGaEybKWH0piWumZTOOfR5-wJOBwwZw%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/django-rest-framework/CA%2Bx7ZMq7iMmi4PaQ9aBjGaEybKWH0piWumZTOOfR5-wJOBwwZw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
>
> -------------------------------------------------------------------------------
> Carl J. Nobile (Software Engineer)
> carl....@gmail.com <javascript:>
>
> -------------------------------------------------------------------------------
>

-- 
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 django-rest-framework+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-rest-framework/c334d97b-6e23-4ec5-808e-6fc1bb4379c3o%40googlegroups.com.

Reply via email to