jeudi 1 janvier 2015

tastypie: why reference objects using uris rather than ids?


Vote count:

0




When creating or editing a model that contains a reference/foreign key to another object, you have to use the uri of that object. For example, imagine we have two classes: User and Group. Each Group has many Users and each User can belong to exactly one group.


Then, if we are creating a User, we might send an object that looks like this:



{"name":"John Doe", "group":"/path/to/group/1/"}


instead of



{"name":"John Doe", "group_id":1}


I believe this is related to one of the principles of HATEOAS, but I can't find the rationale for using the resource uri rather than the id. What are some reasons for using the uri?


(I'm not interested in opinions about which is better, but in any resources that can help me understand this design choice.)



asked 53 secs ago

Denise

1,133






tastypie: why reference objects using uris rather than ids?

Aucun commentaire:

Enregistrer un commentaire