[Answer]-Tastypie using itertools chain

1πŸ‘

βœ…

Have you tried converting itertools.chain to a list:

queryset = list(chain(jobdtlquery, jobmstquery))

Update You can concatenate the queries on the same model like this:

queryset = query1 | query2

Update As the error message implies, your queryset has to have only one model. You cannot achieve your goal with two different models.

This question seems like a dublicate.

πŸ‘€niekas

0πŸ‘

Because a ResourceModel is made to allow a REST client to make queries that filter, paginate and sort, which then trigger the appropriate SQL query, it’s not possible to just use an iterator which cannot be as flexible.

Maybe you can hack something that works but looks like the cleanest stuff is to use a plain Resource and add your own logic. See this answer Tastypie: How can I fill the resource without database? which refers to Resource VS ModelResource in the documentation http://django-tastypie.readthedocs.org/en/latest/resources.html#why-resource-vs-modelresource

πŸ‘€vincent

Leave a comment