Hi,

> Le 17 oct. 2016 à 23:23, Brian Stempin <brian.stem...@gmail.com> a écrit :
> 
> Hi,
> I'm trying to hyperlink to a filtered list.  Let's say I have these 
> resources:  User and Transaction.  A User has many Transactions, and each 
> Transaction has exactly one User.  Because a User could have hundreds of 
> transactions, I don't want the user to serialize like this:
> 
> [{"id": 1, "transactions": [ hundreds of transaction URLs here ]}]
> 
> but rather like this:
> 
> [{"id": 1, "transactions": "http://server/transactions?user=1"; }]
> 
> This way, the REST client could follow the URL and even apply additional 
> filtering if it so desired.
> 
> Is there an easy way to do this?  I seem to not be having any luck with 
> HyperlinkedRelatedField.
> 
> Thanks,
> Brian

I don’t think you could have an out of the box solution for it.
You need knowledge of the entry point url and the filter name.
The best solution I can think of being to make a property out of a function in 
the User that reverse the entry point url and add the filter yourself.

Regards,
Xavier,
Linovia.

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to