#How to handle multiple of multiple [[ids], [ids], [ids]] in django?

6 messages · Page 1 of 1 (latest)

hot tiger
#

We have a use case where the django backend api endpoint has to take a [[ids], [ids], [ids]] as the GET endpoint input, any idea how to handle this in Django rest framework?

shut leaf
#

@hot tiger you can use ids=1,2,3,4,5 and in DRF just split the string ids = ids.split(",") then you will get array of ids so after that just User.objects.filter(id__in=ids)

hot tiger
#

@shut leaf it's a little tricky, it turned out that the front-end is expecting user[0]=id&user[0]=id&user[1]=id, and want to return different list of user objects from db

shut leaf
#

Is that a filter? @hot tiger

hot tiger
#

it's like nested query where i have to get all the users given the user-ids, but the user-ids come in in sub-lists, like [[user-ids], [user-ids]]

amber seal
#

You can make a post passing this list as payload and treat this data in the view