Hello ,

You can design a serializer for each api endpoint and use it in your view
to validate your data like validating forms data :
Pseducode :
res = requests.post(url+some_endpoint, data)
endpoint_serializer.validate(res.data)
if serializer.is_valid():
    #do your stuff
else :
    #do something

Best Regards

Ammar Mohammed

On Fri, 2 Sep 2022, 01:41 [email protected], <[email protected]> wrote:

> Hello all,
>
>     I am sending an GET request to an external API and I would like to
> validate the response before I save it to my model.  How do I do this?
>
> Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" 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-users/0b724dc1-cb08-4168-8cc0-a5eac8a7c011n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/0b724dc1-cb08-4168-8cc0-a5eac8a7c011n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" 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-users/CAHs1H7spUzCOMX%2BDs9%3D25ackprZ86GPBBBwS5a_ig9Ca%3DzTMog%40mail.gmail.com.

Reply via email to