0

I am building a REST API in which unique objects are owned by users. So URI's need (project requirement) to be formatted like so:

/api/v1/user/[user_slug]/book/[book_isbn]

example:

http://library.edu/api/v1/user/jack@gmail.com/book/1481879707

or

http://library.edu/api/v1/user/jill@gmail.com/book/1481879707 

Both are unique objects

enter code here

How do I use tastypie to do this?

4

1 回答 1

0

我认为您需要在资源中编写一个 prepend_urls 方法,正如 Tastypie 文档的本节所述:

Tastypie Doc - 食谱#nested-resources

您将拥有您的 Books 资源,而不是 Children,您还将进行更改以适应您的 URL 模式。

于 2013-09-21T03:34:29.493 回答