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

Now I want to combine these two queryset, any good way to do that? Thanks for your help!

user469652
  • 48,855
  • 59
  • 128
  • 165
  • 1
    possible duplicate of [How to combine 2 or more querysets in a Django view?](http://stackoverflow.com/questions/431628/how-to-combine-2-or-more-querysets-in-a-django-view) – Sam Dolan Jan 31 '11 at 23:41

1 Answers1

0

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.

rewritten
  • 16,280
  • 2
  • 47
  • 50