possible to filter the queryset after querying? django

后端 未结 4 1994
失恋的感觉
失恋的感觉 2020-12-31 01:50

Sorry if the question sounds weird. I am just wondering if there is possible to make new queryset when I already have a queryset.

For example here...



        
4条回答
  •  [愿得一人]
    2020-12-31 02:08

    The best you can do is:

    active_users = User.objects.filter(active=True)
    not_deleted = active_users.filter(is_deleted=False)
    deleted = active_users.filter(is_deleted=True)
    

    So the answer to your question may be yes, if I understand it correctly.

提交回复
热议问题