Hello Guilherme,

The easy way is provide an endpoint with valid values for that relation.
Other than that, the client doesn't need to know about that. He can post
anything and you can answer back with the errors.

If he posts, for example, an invalid gender, you can validate that in your
DRF and just spit out the errors for the client.

But there is no other way (that I can see) to let the client configure
itself, without having a valid values list for that.

On Wed, Jul 5, 2017 at 3:17 PM, Guilherme Leal <lealhu...@gmail.com> wrote:

> I'm starting a new project that uses Django (with DRF) as backend and
> React as frontend but I have some concerns about data consistency across
> what the API endpoints might expect, and what the client with React could
> provide.
>
> Exemple:
>
> Lets say I have the following model:
>
> class Person(models.Model):
>     name = models.CharField(max_length=250)
>     gender = models.IntegerField(choices=MY_GENDER_CHOICES)
>
> If one would build an API endpoint for exclusively this model, the
> endpoint would answer with the fields 'name' and 'gender' everytime it
> would be "GETed", or would accept only the fields 'name' and 'gender' when
> "POSTed'. Furthermore, in both cases the 'gender' field have a limited set
> of values it can answer/accept.
>
> The concern I was talking about is HOW THE HELL am I going to tell the
> client that he only can use "this" or "that" limited set of fields or
> values? Even more, I want to teach the client how to discover this info, or
> simply put, share model specification between "client" and "server".
>
> One thing to note: I did looked over React+Relay+GraphQL. The features are
> almost exactly what I was looking for, but I did find it really really
> really overcomplex for the size of the project I have in mind.
>
> Anyone have anything in mind to help or sujest?
>
> --
> 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAOs3Lp6cp8vm403D0nWd%2B09-
> PDZKZQOcaBcU2dvNi7LUA--%2BeA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAOs3Lp6cp8vm403D0nWd%2B09-PDZKZQOcaBcU2dvNi7LUA--%2BeA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
George R. C. Silva
Sigma Geosistemas LTDA
----------------------------
http://www.sigmageosistemas.com.br/

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGyPVTvwGXOamNKtsWGyaGG-q%2BkEHXg7BTw3QBxCCeU1P6w%3D8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to