开发者

Django query: Combine two queryset in django

employees = Employee.objects.all()
staff = Staff.objects.all()

Now I want to combine these two queryset, any good way to do that? Thanks 开发者_Python百科for your help!


If both models inherit from the same superclass, you'd better query the superclass, and use the OneToOne automatic accessors to the subclasses to filter the query.

On the other side, if the two models are unrelated at the database level there is no easy way to (filter|offset|limit) both queries, neither in pure SQL. Just make them into lists and use them as they are.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜