Sunday, February 26, 2017

Re: Flattening model relationships (in APIs)



On Tuesday, February 21, 2017 at 8:13:25 PM UTC+1, Ankush Thakur wrote:
If the relationship chain was even deeper, there would be even more nesting, which I feel isn't great for API consumers. What is the best practice here to put state and country at the same level as the city? 

Just follow REST design. 
Forget django models, think about encapsulation.
Think about representation of a resource, not about serializing a model(s).
Make semantic representations, as good as possible.

You are not forced to do any nested nasty things. This has nothing to do with REST api.
You may feel that DRF is limiting you. You'll be on a good path, if so. :)

Good luck!
Marcin

--
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+unsubscribe@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/9d0ad41b-094d-4211-9e69-9fbb89c84395%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment